java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<V>, java.util.Map<K,V>, java.util.SortedMap<K,V>, InternalIterable<V>, MapIterable<K,V>, MutableMapIterable<K,V>, MutableSortedMap<K,V>, SortedMapIterable<K,V>, OrderedIterable<V>, ReversibleIterable<V>, RichIterable<V>public class TreeSortedMap<K,V> extends AbstractMutableSortedMap<K,V> implements java.io.Externalizable
| Constructor | Description |
|---|---|
TreeSortedMap() |
|
TreeSortedMap(java.util.Comparator<? super K> comparator) |
|
TreeSortedMap(java.util.Comparator<? super K> comparator,
java.util.Map<? extends K,? extends V> map) |
|
TreeSortedMap(java.util.Map<? extends K,? extends V> map) |
|
TreeSortedMap(java.util.SortedMap<K,? extends V> map) |
|
TreeSortedMap(Pair<K,V>... pairs) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
clear() |
|
TreeSortedMap<K,V> |
clone() |
|
java.util.Comparator<? super K> |
comparator() |
|
boolean |
containsKey(java.lang.Object key) |
|
boolean |
containsValue(java.lang.Object value) |
|
MutableList<V> |
distinct() |
Returns a new
OrderedIterable containing the distinct elements in this iterable. |
MutableSortedMap<K,V> |
drop(int count) |
Returns an iterable after skipping the first
count elements
or an empty iterable if the count is greater than the length of the iterable. |
MutableSortedMap<K,V> |
dropWhile(Predicate<? super V> predicate) |
Returns the final elements that do not satisfy the Predicate.
|
MutableSet<java.util.Map.Entry<K,V>> |
entrySet() |
|
boolean |
equals(java.lang.Object o) |
Follows the same general contract as
Map.equals(Object). |
K |
firstKey() |
|
void |
forEachKeyValue(Procedure2<? super K,? super V> procedure2) |
Calls the
procedure with each key-value pair of the map. |
V |
get(java.lang.Object key) |
|
int |
hashCode() |
Follows the same general contract as
Map.hashCode(). |
MutableSortedMap<K,V> |
headMap(K toKey) |
|
MutableSet<K> |
keySet() |
The underlying set for the keys is sorted in ascending order according to their natural ordering or a custom comparator.
|
K |
lastKey() |
|
MutableSortedMap<K,V> |
newEmpty() |
Creates a new instance of the same type with the same internal Comparator.
|
static <K,V> TreeSortedMap<K,V> |
newMap() |
|
static <K,V> TreeSortedMap<K,V> |
newMap(java.util.Comparator<? super K> comparator) |
|
static <K,V> TreeSortedMap<K,V> |
newMap(java.util.Comparator<? super K> comparator,
java.util.Map<? extends K,? extends V> map) |
|
static <K,V> TreeSortedMap<K,V> |
newMap(java.util.Map<? extends K,? extends V> map) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(java.util.Comparator<? super K> comparator,
K key,
V value) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(java.util.Comparator<? super K> comparator,
K key1,
V value1,
K key2,
V value2) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(java.util.Comparator<? super K> comparator,
K key1,
V value1,
K key2,
V value2,
K key3,
V value3) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(java.util.Comparator<? super K> comparator,
K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(java.util.Comparator<? super K> comparator,
Pair<K,V>... pairs) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(K key,
V value) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(K key1,
V value1,
K key2,
V value2) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(K key1,
V value1,
K key2,
V value2,
K key3,
V value3) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4) |
|
static <K,V> TreeSortedMap<K,V> |
newMapWith(Pair<K,V>... pairs) |
|
PartitionMutableList<V> |
partitionWhile(Predicate<? super V> predicate) |
Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.
|
V |
put(K key,
V value) |
|
void |
putAll(java.util.Map<? extends K,? extends V> map) |
|
void |
readExternal(java.io.ObjectInput in) |
|
V |
remove(java.lang.Object key) |
|
V |
removeKey(K key) |
Remove an entry from the map at the specified
key. |
int |
size() |
Returns the number of items in this iterable.
|
MutableSortedMap<K,V> |
subMap(K fromKey,
K toKey) |
|
MutableSortedMap<K,V> |
tailMap(K fromKey) |
|
MutableSortedMap<K,V> |
take(int count) |
Returns the first
count elements of the iterable
or all the elements in the iterable if count is greater than the length of
the iterable. |
MutableSortedMap<K,V> |
takeWhile(Predicate<? super V> predicate) |
Returns the initial elements that satisfy the Predicate.
|
MutableSortedMap<K,V> |
toReversed() |
Returns a new ReversibleIterable in reverse order.
|
java.lang.String |
toString() |
Returns a string with the elements of the iterable separated by commas with spaces and
enclosed in square brackets.
|
MutableCollection<V> |
values() |
|
TreeSortedMap<K,V> |
with(K key,
V value) |
|
TreeSortedMap<K,V> |
with(K key1,
V value1,
K key2,
V value2) |
|
TreeSortedMap<K,V> |
with(K key1,
V value1,
K key2,
V value2,
K key3,
V value3) |
|
TreeSortedMap<K,V> |
with(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4) |
|
TreeSortedMap<K,V> |
with(Pair<K,V>... pairs) |
|
void |
writeExternal(java.io.ObjectOutput out) |
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArrayaggregateBy, aggregateInPlaceBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, iterator, keysView, keyValuesView, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWith, valuesViewasReversed, asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectKeysAndValues, collectLong, collectShort, collectValues, collectWith, corresponds, detectIndex, detectLastIndex, flatCollect, flip, forEach, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, indexOf, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, tap, toImmutable, toStack, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexappendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexforEach, forEachWithcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAlldetect, detectOptional, forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, keysView, keyValuesView, parallelStream, spliterator, stream, valuesViewadd, aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWithKey, putPair, removeAllKeys, removeIf, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWithcollect, collectWithIndex, flatCollectWith, getIfAbsentPutWithcollectWithIndex, forEachWithIndex, getFirst, getFirstOptional, getLast, getLastOptional, max, min, zip, zipWithIndexreverseForEach, reverseForEachWithIndexallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBypublic TreeSortedMap()
public TreeSortedMap(java.util.Comparator<? super K> comparator)
public TreeSortedMap(java.util.Comparator<? super K> comparator, java.util.Map<? extends K,? extends V> map)
public static <K,V> TreeSortedMap<K,V> newMap()
public static <K,V> TreeSortedMap<K,V> newMap(java.util.Comparator<? super K> comparator)
public static <K,V> TreeSortedMap<K,V> newMap(java.util.Map<? extends K,? extends V> map)
public static <K,V> TreeSortedMap<K,V> newMap(java.util.Comparator<? super K> comparator, java.util.Map<? extends K,? extends V> map)
public static <K,V> TreeSortedMap<K,V> newMapWith(Pair<K,V>... pairs)
public static <K,V> TreeSortedMap<K,V> newMapWith(java.util.Comparator<? super K> comparator, Pair<K,V>... pairs)
public static <K,V> TreeSortedMap<K,V> newMapWith(K key, V value)
public static <K,V> TreeSortedMap<K,V> newMapWith(K key1, V value1, K key2, V value2)
public static <K,V> TreeSortedMap<K,V> newMapWith(K key1, V value1, K key2, V value2, K key3, V value3)
public static <K,V> TreeSortedMap<K,V> newMapWith(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
public static <K,V> TreeSortedMap<K,V> newMapWith(java.util.Comparator<? super K> comparator, K key, V value)
public static <K,V> TreeSortedMap<K,V> newMapWith(java.util.Comparator<? super K> comparator, K key1, V value1, K key2, V value2)
public static <K,V> TreeSortedMap<K,V> newMapWith(java.util.Comparator<? super K> comparator, K key1, V value1, K key2, V value2, K key3, V value3)
public static <K,V> TreeSortedMap<K,V> newMapWith(java.util.Comparator<? super K> comparator, K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
public TreeSortedMap<K,V> with(K key, V value)
public TreeSortedMap<K,V> with(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
public TreeSortedMap<K,V> with(Pair<K,V>... pairs)
with in interface MutableSortedMap<K,V>public int size()
RichIterablesize in interface java.util.Map<K,V>size in interface RichIterable<K>public MutableSortedMap<K,V> newEmpty()
MutableSortedMapnewEmpty in interface MutableMapIterable<K,V>newEmpty in interface MutableSortedMap<K,V>public V removeKey(K key)
MutableMapIterablekey.removeKey in interface MutableMapIterable<K,V>Map.remove(Object)public TreeSortedMap<K,V> clone()
clone in interface MutableSortedMap<K,V>clone in class AbstractMutableSortedMap<K,V>public boolean equals(java.lang.Object o)
MapIterableMap.equals(Object).public int hashCode()
MapIterableMap.hashCode().public void forEachKeyValue(Procedure2<? super K,? super V> procedure2)
MapIterableprocedure with each key-value pair of the map.
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");
forEachKeyValue in interface MapIterable<K,V>public MutableSet<java.util.Map.Entry<K,V>> entrySet()
public MutableSet<K> keySet()
MutableSortedMappublic MutableCollection<V> values()
public java.util.Comparator<? super K> comparator()
comparator in interface java.util.SortedMap<K,V>comparator in interface SortedMapIterable<K,V>public V get(java.lang.Object key)
public boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<K,V>containsKey in interface MapIterable<K,V>Map.containsKey(Object)public MutableSortedMap<K,V> headMap(K toKey)
public MutableSortedMap<K,V> tailMap(K fromKey)
public MutableSortedMap<K,V> subMap(K fromKey, K toKey)
public boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Map<K,V>containsValue in interface MapIterable<K,V>Map.containsValue(Object)public MutableSortedMap<K,V> toReversed()
ReversibleIterabletoReversed in interface MutableSortedMap<K,V>toReversed in interface ReversibleIterable<K>toReversed in interface SortedMapIterable<K,V>public MutableSortedMap<K,V> take(int count)
ReversibleIterablecount elements of the iterable
or all the elements in the iterable if count is greater than the length of
the iterable.take in interface MutableSortedMap<K,V>take in interface ReversibleIterable<K>take in interface SortedMapIterable<K,V>count - the number of items to take.public MutableSortedMap<K,V> takeWhile(Predicate<? super V> predicate)
ReversibleIterabletakeWhile in interface MutableSortedMap<K,V>takeWhile in interface OrderedIterable<K>takeWhile in interface ReversibleIterable<K>takeWhile in interface SortedMapIterable<K,V>public MutableSortedMap<K,V> drop(int count)
ReversibleIterablecount elements
or an empty iterable if the count is greater than the length of the iterable.drop in interface MutableSortedMap<K,V>drop in interface ReversibleIterable<K>drop in interface SortedMapIterable<K,V>count - the number of items to drop.public MutableSortedMap<K,V> dropWhile(Predicate<? super V> predicate)
ReversibleIterabledropWhile in interface MutableSortedMap<K,V>dropWhile in interface OrderedIterable<K>dropWhile in interface ReversibleIterable<K>dropWhile in interface SortedMapIterable<K,V>public PartitionMutableList<V> partitionWhile(Predicate<? super V> predicate)
OrderedIterablepartitionWhile in interface MutableSortedMap<K,V>partitionWhile in interface OrderedIterable<K>partitionWhile in interface ReversibleIterable<K>partitionWhile in interface SortedMapIterable<K,V>public MutableList<V> distinct()
OrderedIterableOrderedIterable containing the distinct elements in this iterable.
Conceptually similar to RichIterable.toSet().RichIterable.toList() but retains the original order. If an element appears
multiple times in this iterable, the first one will be copied into the result.
distinct in interface MutableSortedMap<K,V>distinct in interface OrderedIterable<K>distinct in interface ReversibleIterable<K>distinct in interface SortedMapIterable<K,V>OrderedIterable of distinct elementspublic java.lang.String toString()
AbstractRichIterable
Assert.assertEquals("[]", Lists.mutable.empty().toString());
Assert.assertEquals("[1]", Lists.mutable.with(1).toString());
Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());
toString in interface MapIterable<K,V>toString in interface RichIterable<K>toString in class AbstractRichIterable<V>AbstractCollection.toString()public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundExceptionCopyright © 2004–2020. All rights reserved.