ImmutableSortedMap
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| protected class |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator | |
| private final K[] | |
| private final V[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Comparator | comparator()
Implements org. Returns the comparator used to order the keys in this map, or
|
| public boolean | containsKey(Object key)
Implements org. Returns |
| public boolean | containsValue(Object value)
Implements org. Returns |
| public ImmutableSortedMap | drop(int count)
Implements org. Returns an iterable after skipping the first |
| public Set | entrySet()
Implements java. Returns a |
| public boolean | equals(Object object)
Overrides java. Implements org. Follows the same general contract as |
| public K | firstKey()
Implements java. Returns the first (lowest) key currently in this map. |
| public ImmutableMap | flipUniqueValues()
Implements org. Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key. |
| public void | forEachKeyValue(Procedure2<? super K, ? super V> procedure)
Implements org. Calls the |
| public V | get(Object key)
Implements org. Returns the value to which the specified key is mapped,
or |
| public int | hashCode()
Overrides java. Implements org. Follows the same general contract as |
| public Set | keySet()
Implements java. Returns a |
| public RichIterable | keysView()
Implements org. Returns an unmodifiable lazy iterable wrapped around the keySet for the map. |
| public RichIterable | keyValuesView()
Implements org. Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map. |
| public K | lastKey()
Implements java. Returns the last (highest) key currently in this map. |
| public static <K, V> ImmutableSortedMap | |
| public int | size()
Implements org. Returns the number of items in this iterable. |
| public ImmutableSortedMap | take(int count)
Implements org. Returns the first |
| public String | toString()
Overrides org. Implements org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. |
| public Collection | values()
Implements java. Returns a |
| public RichIterable | valuesView()
Implements org. Returns an unmodifiable lazy iterable wrapped around the values for the map. |
| protected Object |
| comparator | back to summary |
|---|---|
| private final Comparator<? super K> comparator | |
| keys | back to summary |
|---|---|
| private final K[] keys | |
| values | back to summary |
|---|---|
| private final V[] values | |
| ImmutableTreeMap | back to summary |
|---|---|
| public ImmutableTreeMap(SortedMap<K, V> sortedMap) | |
| comparator | back to summary |
|---|---|
| public Comparator Implements org. Doc from java. Returns the comparator used to order the keys in this map, or
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Implements org. Doc from java. Returns
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Implements org. Doc from java. Returns
| |
| drop | back to summary |
|---|---|
| public ImmutableSortedMap Implements org. Doc from org. Returns an iterable after skipping the first
| |
| entrySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Implements org. Doc from org. Follows the same general contract as
| |
| firstKey | back to summary |
|---|---|
| public K firstKey() Implements java. Doc from java. Returns the first (lowest) key currently in this map.
| |
| flipUniqueValues | back to summary |
|---|---|
| public ImmutableMap Implements org. Doc from org. Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key.
MapIterable<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
MapIterable<String, Integer> result = map.flipUniqueValues();
Assert.assertTrue(result.equals(UnifiedMap.newWithKeysValues("1", 1, "2", 2, "3", 3)));
| |
| forEachKeyValue | back to summary |
|---|---|
| public void forEachKeyValue(Procedure2<? super K, ? super V> procedure) Implements org. Doc from org. Calls the
final Collection<String> collection = new ArrayList<String>();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three");
map.forEachKeyValue((Integer key, String value) -> collection.add(String.valueOf(key) + value));
Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
| |
| get | back to summary |
|---|---|
| public V get(Object key) Implements org. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements org. Doc from org. Follows the same general contract as
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a
| |
| keysView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable wrapped around the keySet for the map.
| |
| keyValuesView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.
| |
| lastKey | back to summary |
|---|---|
| public K lastKey() Implements java. Doc from java. Returns the last (highest) key currently in this map.
| |
| newMap | back to summary |
|---|---|
| public static <K, V> ImmutableSortedMap | |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from org. Returns the number of items in this iterable.
| |
| take | back to summary |
|---|---|
| public ImmutableSortedMap Implements org. Doc from org. Returns the first
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Implements org. Doc from org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. Each key and value is separated by an equals sign.
Assert.assertEquals("{1=1, 2=2, 3=3}", Maps.mutable.with(1, 1, 2, 2, 3, 3).toString());
| |
| values | back to summary |
|---|---|
| public Collection Implements java. Doc from java. Returns a
| |
| valuesView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable wrapped around the values for the map.
| |
| writeReplace | back to summary |
|---|---|
| protected Object writeReplace() | |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int |
| comparator | back to summary |
|---|---|
| private final Comparator<? super K> comparator | |
| EntryComparator | back to summary |
|---|---|
| private EntryComparator(Comparator<? super K> comparator) | |
| compare | back to summary |
|---|---|
| public int compare(Map. Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(K key)
Overrides java. Implements java. Adds the specified element to this set if it is not already present (optional operation). |
| public boolean | addAll(Collection<? extends K> collection)
Overrides java. Implements java. Adds all of the elements in the specified collection to this set if they're not already present (optional operation). |
| public void | clear()
Overrides java. Implements java. Removes all of the elements from this set (optional operation). |
| public boolean | contains(Object o)
Overrides java. Implements java. Returns |
| public boolean | containsAll(Collection<?> collection)
Overrides java. Implements java. Returns |
| public Iterator | iterator()
Implements abstract java. Implements java. Returns an iterator over the elements in this set. |
| public boolean | remove(Object key)
Overrides java. Implements java. Removes the specified element from this set if it is present (optional operation). |
| public boolean | removeAll(Collection<?> collection)
Overrides java. Implements java. Removes from this set all of its elements that are contained in the specified collection (optional operation). |
| public boolean | retainAll(Collection<?> collection)
Overrides java. Implements java. Retains only the elements in this set that are contained in the specified collection (optional operation). |
| public int | size()
Implements abstract java. Implements java. Returns the number of elements in this set (its cardinality). |
| public Object[] | toArray()
Overrides java. Implements java. Returns an array containing all of the elements in this set. |
| public <T> T[] | toArray(T[] a)
Overrides java. Implements java. Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. |
| protected Object |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ImmutableSortedMapKeySet | back to summary |
|---|---|
| protected ImmutableSortedMapKeySet() | |
| add | back to summary |
|---|---|
| public boolean add(K key) Overrides java. Implements java. Doc from java. Adds the specified element to this set if it is not already present
(optional operation). More formally, adds the specified element
The stipulation above does not imply that sets must accept all
elements; sets may refuse to add any particular element, including
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(Collection<? extends K> collection) Overrides java. Implements java. Doc from java. Adds all of the elements in the specified collection to this set if
they're not already present (optional operation). If the specified
collection is also a set, the
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this set (optional operation). The set will be empty after this call returns.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Object o) Overrides java. Implements java. Doc from java. Returns
| |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(Collection<?> collection) Overrides java. Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).
| |
| remove | back to summary |
|---|---|
| public boolean remove(Object key) Overrides java. Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element
| |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> collection) Overrides java. Implements java. Doc from java. Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets. This implementation determines which is the smaller of this set
and the specified collection, by invoking the Note that this implementation will throw an
| |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> collection) Overrides java. Implements java. Doc from java. Retains only the elements in this set that are contained in the specified collection (optional operation). In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| toArray | back to summary |
|---|---|
| public Object[] toArray() Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs.
| |
| toArray | back to summary |
|---|---|
| public <T> T[] toArray(T[] a) Overrides java. Implements java. Doc from java. Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set. If this set fits in the specified array with room to spare
(i.e., the array has more elements than this set), the element in
the array immediately following the end of the set is set to
If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. Like the Suppose
String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to
toArray().
| |
| writeReplace | back to summary |
|---|---|
| protected Object writeReplace() | |