To create a new wrapper around an existing SortedMap instance, use the adapt(SortedMap) factory method.
| Modifier and Type | Field and Description |
|---|---|
| private final SortedMap | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static <K, V> MutableSortedMap | |
| public void | clear()
Implements java. Removes all of the mappings from this map (optional operation). |
| public MutableSortedMap | clone()
Implements abstract org. Implements org. Creates and returns a copy of this object. |
| 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 MutableList | distinct()
Implements org. Returns a new |
| public MutableSortedMap | drop(int count)
Implements org. Returns an iterable after skipping the first |
| public MutableSortedMap | dropWhile(Predicate<? super V> predicate)
Implements org. Returns the final elements that do not satisfy the Predicate. |
| public MutableSet | entrySet()
Implements org. Returns a |
| public boolean | equals(Object o)
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 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 MutableSortedMap | headMap(K toKey)
Implements org. Returns a view of the portion of this map whose keys are
strictly less than |
| public boolean | isEmpty()
Overrides org. Implements org. Returns |
| public Iterator | iterator()
Overrides org. Implements java. Returns an iterator over elements of type |
| public MutableSet | keySet()
Implements org. The underlying set for the keys is sorted in ascending order according to their natural ordering or a custom comparator. |
| public K | lastKey()
Implements java. Returns the last (highest) key currently in this map. |
| public V | merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction)
Overrides default java. If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value (optional operation). |
| public MutableSortedMap | newEmpty()
Implements org.
Deprecated
use
TreeSortedMap#newEmpty() instead (inlineable)
Creates a new instance of the same type with the same internal Comparator. |
| public PartitionMutableList | partitionWhile(Predicate<? super V> predicate)
Implements org. Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements. |
| public V | put(K key, V value)
Implements java. Associates the specified value with the specified key in this map (optional operation). |
| public void | putAll(Map<? extends K, ? extends V> map)
Implements java. Copies all of the mappings from the specified map to this map (optional operation). |
| public V | remove(Object key)
Implements java. Removes the mapping for a key from this map if it is present (optional operation). |
| public V | removeKey(K key)
Implements org. Remove an entry from the map at the specified |
| public int | size()
Implements org. Returns the number of key-value mappings in this map. |
| public MutableSortedMap | subMap(K fromKey, K toKey)
Implements org. Returns a view of the portion of this map whose keys range from
|
| public MutableSortedMap | tailMap(K fromKey)
Implements org. Returns a view of the portion of this map whose keys are
greater than or equal to |
| public MutableSortedMap | take(int count)
Implements org. Returns the first |
| public MutableSortedMap | takeWhile(Predicate<? super V> predicate)
Implements org. Returns the initial elements that satisfy the Predicate. |
| public MutableSortedMap | toReversed()
Implements org. Returns a new ReversibleIterable in reverse order. |
| 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 MutableCollection | values()
Implements org. Returns a |
| public MutableSortedMap | with(Pair<K, V>... pairs)
Overrides default org.
|
| delegate | back to summary |
|---|---|
| private final SortedMap<K, V> delegate | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| SortedMapAdapter | back to summary |
|---|---|
| protected SortedMapAdapter(SortedMap<K, V> newDelegate) | |
| adapt | back to summary |
|---|---|
| public static <K, V> MutableSortedMap | |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Doc from java. Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| clone | back to summary |
|---|---|
| public MutableSortedMap Implements abstract org. Implements org. Doc from java. Creates and returns a copy of this object. The precise meaning
of "copy" may depend on the class of the object. The general
intent is that, for any object will be true, and that the expression:x.clone() != x will bex.clone().getClass() == x.getClass() true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x) true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by
| |
| 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
| |
| distinct | back to summary |
|---|---|
| public MutableList Implements org. Doc from org. Returns a new
Conceptually similar to
| |
| drop | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from org. Returns an iterable after skipping the first
| |
| dropWhile | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from org. Returns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.
| |
| entrySet | back to summary |
|---|---|
| public MutableSet Implements org. Doc from java. Returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) 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.
| |
| 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
| |
| headMap | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from java. Returns a view of the portion of this map whose keys are
strictly less than The returned map will throw an
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides org. Implements org. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Overrides org. Implements java. Doc from java. Returns an iterator over elements of type
| |
| keySet | back to summary |
|---|---|
| public MutableSet Implements org. Doc from org. The underlying set for the keys is sorted in ascending order according to their natural ordering or a custom comparator. However, Java 5 TreeMap returns a keySet that does not inherit from SortedSet therefore we have decided to return the keySet simply as a MutableSet to maintain Java 5 compatibility.
| |
| lastKey | back to summary |
|---|---|
| public K lastKey() Implements java. Doc from java. Returns the last (highest) key currently in this map.
| |
| merge | back to summary |
|---|---|
| public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) Overrides default java. Doc from java. If the specified key is not already associated with a value or is
associated with null, associates it with the given non-null value (optional
operation). Otherwise, replaces the associated value with the results of
the given remapping function, or removes if the result is
If the remapping function returns The remapping function should not modify this map during computation.
| |
| newEmpty | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from org. Deprecated use Creates a new instance of the same type with the same internal Comparator.
| |
| partitionWhile | back to summary |
|---|---|
| public PartitionMutableList Implements org. Doc from org. Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements. Short circuits at the first element which does satisfy the Predicate.
| |
| put | back to summary |
|---|---|
| public V put(K key, V value) Implements java. Doc from java. Associates the specified value with the specified key in this map
(optional operation). If the map previously contained a mapping for
the key, the old value is replaced by the specified value. (A map
| |
| putAll | back to summary |
|---|---|
| public void putAll(Map<? extends K, ? extends V> map) Implements java. Doc from java. Copies all of the mappings from the specified map to this map
(optional operation). The effect of this call is equivalent to that
of calling
| |
| remove | back to summary |
|---|---|
| public V remove(Object key) Implements java. Doc from java. Removes the mapping for a key from this map if it is present
(optional operation). More formally, if this map contains a mapping
from key Returns the value to which this map previously associated the key,
or If this map permits null values, then a return value of
The map will not contain a mapping for the specified key once the call returns.
| |
| removeKey | back to summary |
|---|---|
| public V removeKey(K key) Implements org. Doc from org. Remove an entry from the map at the specified
| |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| subMap | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from java. Returns a view of the portion of this map whose keys range from
The returned map will throw an
| |
| tailMap | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from java. Returns a view of the portion of this map whose keys are
greater than or equal to The returned map will throw an
| |
| take | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from org. Returns the first
| |
| takeWhile | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from org. Returns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.
| |
| toReversed | back to summary |
|---|---|
| public MutableSortedMap Implements org. Doc from org. Returns a new ReversibleIterable in reverse order.
| |
| 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 MutableCollection Implements org. Doc from java. Returns a
| |
| with | back to summary |
|---|---|
| public MutableSortedMap Overrides default org.
| |