Class TreeSortedMap<K,V>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<V>
org.eclipse.collections.impl.map.AbstractMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable<K,V>
org.eclipse.collections.impl.map.sorted.mutable.AbstractMutableSortedMap<K,V>
org.eclipse.collections.impl.map.sorted.mutable.TreeSortedMap<K,V>
- All Implemented Interfaces:
Externalizable
,Serializable
,Cloneable
,Iterable<V>
,Map<K,V>
,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 Externalizable
- See Also:
- Serialized Form
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description TreeSortedMap()
TreeSortedMap(Comparator<? super K> comparator)
TreeSortedMap(Comparator<? super K> comparator, Map<? extends K,? extends V> map)
TreeSortedMap(Map<? extends K,? extends V> map)
TreeSortedMap(SortedMap<K,? extends V> map)
TreeSortedMap(Pair<K,V>... pairs)
-
Method Summary
Modifier and Type Method Description void
clear()
TreeSortedMap<K,V>
clone()
Comparator<? super K>
comparator()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
MutableList<V>
distinct()
Returns a newOrderedIterable
containing the distinct elements in this iterable.MutableSortedMap<K,V>
drop(int count)
Returns an iterable after skipping the firstcount
elements or an empty iterable if thecount
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<Map.Entry<K,V>>
entrySet()
boolean
equals(Object o)
Follows the same general contract asMap.equals(Object)
.K
firstKey()
void
forEachKeyValue(Procedure2<? super K,? super V> procedure2)
Calls theprocedure
with each key-value pair of the map.V
get(Object key)
int
hashCode()
Follows the same general contract asMap.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(Comparator<? super K> comparator)
static <K, V> TreeSortedMap<K,V>
newMap(Comparator<? super K> comparator, Map<? extends K,? extends V> map)
static <K, V> TreeSortedMap<K,V>
newMap(Map<? extends K,? extends V> map)
static <K, V> TreeSortedMap<K,V>
newMapWith(Comparator<? super K> comparator, K key, V value)
static <K, V> TreeSortedMap<K,V>
newMapWith(Comparator<? super K> comparator, K key1, V value1, K key2, V value2)
static <K, V> TreeSortedMap<K,V>
newMapWith(Comparator<? super K> comparator, K key1, V value1, K key2, V value2, K key3, V value3)
static <K, V> TreeSortedMap<K,V>
newMapWith(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(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(Map<? extends K,? extends V> map)
void
readExternal(ObjectInput in)
V
remove(Object key)
V
removeKey(K key)
Remove an entry from the map at the specifiedkey
.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 firstcount
elements of the iterable or all the elements in the iterable ifcount
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.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(ObjectOutput out)
Methods inherited from class org.eclipse.collections.impl.map.sorted.mutable.AbstractMutableSortedMap
asReversed, 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, zipWithIndex
Methods inherited from class org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable
aggregateBy, aggregateInPlaceBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, iterator, keysView, keyValuesView, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWith, valuesView
Methods inherited from class org.eclipse.collections.impl.map.AbstractMapIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, getOrDefault, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArray
Methods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, 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, zipWithIndex
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll
Methods inherited from interface org.eclipse.collections.api.map.MapIterable
detect, detectOptional, forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, keysView, keyValuesView, parallelStream, spliterator, stream, valuesView
Methods inherited from interface org.eclipse.collections.api.map.MutableMapIterable
add, aggregateBy, aggregateBy, aggregateInPlaceBy, countBy, countByEach, countByWith, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWithKey, getOrDefault, putPair, removeAllKeys, removeIf, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWith
Methods inherited from interface org.eclipse.collections.api.map.sorted.MutableSortedMap
collect, collectWithIndex, flatCollectWith, getIfAbsentPutWith, withMap
Methods inherited from interface org.eclipse.collections.api.ordered.OrderedIterable
collectWithIndex, forEachWithIndex, getFirst, getFirstOptional, getLast, getLastOptional, max, min, zip, zipWithIndex
Methods inherited from interface org.eclipse.collections.api.ordered.ReversibleIterable
reverseForEach, reverseForEachWithIndex
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsBy, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, 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, toSortedSetBy
-
Constructor Details
-
TreeSortedMap
public TreeSortedMap() -
TreeSortedMap
-
TreeSortedMap
-
TreeSortedMap
-
TreeSortedMap
-
TreeSortedMap
-
-
Method Details
-
newMap
-
newMap
-
newMap
-
newMap
public static <K, V> TreeSortedMap<K,V> newMap(Comparator<? super K> comparator, Map<? extends K,? extends V> map) -
newMapWith
-
newMapWith
public static <K, V> TreeSortedMap<K,V> newMapWith(Comparator<? super K> comparator, Pair<K,V>... pairs) -
newMapWith
-
newMapWith
-
newMapWith
public static <K, V> TreeSortedMap<K,V> newMapWith(K key1, V value1, K key2, V value2, K key3, V value3) -
newMapWith
public static <K, V> TreeSortedMap<K,V> newMapWith(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4) -
newMapWith
public static <K, V> TreeSortedMap<K,V> newMapWith(Comparator<? super K> comparator, K key, V value) -
newMapWith
public static <K, V> TreeSortedMap<K,V> newMapWith(Comparator<? super K> comparator, K key1, V value1, K key2, V value2) -
newMapWith
public static <K, V> TreeSortedMap<K,V> newMapWith(Comparator<? super K> comparator, K key1, V value1, K key2, V value2, K key3, V value3) -
newMapWith
public static <K, V> TreeSortedMap<K,V> newMapWith(Comparator<? super K> comparator, K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4) -
with
-
with
-
with
-
with
-
with
- Specified by:
with
in interfaceMutableSortedMap<K,V>
-
size
public int size()Description copied from interface:RichIterable
Returns the number of items in this iterable. -
newEmpty
Description copied from interface:MutableSortedMap
Creates a new instance of the same type with the same internal Comparator.- Specified by:
newEmpty
in interfaceMutableMapIterable<K,V>
- Specified by:
newEmpty
in interfaceMutableSortedMap<K,V>
-
removeKey
Description copied from interface:MutableMapIterable
Remove an entry from the map at the specifiedkey
.- Specified by:
removeKey
in interfaceMutableMapIterable<K,V>
- Returns:
- The value removed from entry at key, or null if not found.
- See Also:
Map.remove(Object)
-
clone
- Specified by:
clone
in interfaceMutableSortedMap<K,V>
- Specified by:
clone
in classAbstractMutableSortedMap<K,V>
-
equals
Description copied from interface:MapIterable
Follows the same general contract asMap.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:MapIterable
Follows the same general contract asMap.hashCode()
. -
forEachKeyValue
Description copied from interface:MapIterable
Calls theprocedure
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");
- Specified by:
forEachKeyValue
in interfaceMapIterable<K,V>
-
firstKey
-
lastKey
-
entrySet
-
keySet
Description copied from interface:MutableSortedMap
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. -
values
-
comparator
- Specified by:
comparator
in interfaceSortedMap<K,V>
- Specified by:
comparator
in interfaceSortedMapIterable<K,V>
-
get
- Specified by:
get
in interfaceMap<K,V>
- Specified by:
get
in interfaceMapIterable<K,V>
- See Also:
Map.get(Object)
-
put
-
remove
-
putAll
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,V>
- Specified by:
containsKey
in interfaceMapIterable<K,V>
- See Also:
Map.containsKey(Object)
-
headMap
-
tailMap
-
subMap
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,V>
- Specified by:
containsValue
in interfaceMapIterable<K,V>
- See Also:
Map.containsValue(Object)
-
toReversed
Description copied from interface:ReversibleIterable
Returns a new ReversibleIterable in reverse order.- Specified by:
toReversed
in interfaceMutableSortedMap<K,V>
- Specified by:
toReversed
in interfaceReversibleIterable<K>
- Specified by:
toReversed
in interfaceSortedMapIterable<K,V>
-
take
Description copied from interface:ReversibleIterable
Returns the firstcount
elements of the iterable or all the elements in the iterable ifcount
is greater than the length of the iterable.- Specified by:
take
in interfaceMutableSortedMap<K,V>
- Specified by:
take
in interfaceReversibleIterable<K>
- Specified by:
take
in interfaceSortedMapIterable<K,V>
- Parameters:
count
- the number of items to take.
-
takeWhile
Description copied from interface:ReversibleIterable
Returns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.- Specified by:
takeWhile
in interfaceMutableSortedMap<K,V>
- Specified by:
takeWhile
in interfaceOrderedIterable<K>
- Specified by:
takeWhile
in interfaceReversibleIterable<K>
- Specified by:
takeWhile
in interfaceSortedMapIterable<K,V>
-
drop
Description copied from interface:ReversibleIterable
Returns an iterable after skipping the firstcount
elements or an empty iterable if thecount
is greater than the length of the iterable.- Specified by:
drop
in interfaceMutableSortedMap<K,V>
- Specified by:
drop
in interfaceReversibleIterable<K>
- Specified by:
drop
in interfaceSortedMapIterable<K,V>
- Parameters:
count
- the number of items to drop.
-
dropWhile
Description copied from interface:ReversibleIterable
Returns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.- Specified by:
dropWhile
in interfaceMutableSortedMap<K,V>
- Specified by:
dropWhile
in interfaceOrderedIterable<K>
- Specified by:
dropWhile
in interfaceReversibleIterable<K>
- Specified by:
dropWhile
in interfaceSortedMapIterable<K,V>
-
partitionWhile
Description copied from interface:OrderedIterable
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.- Specified by:
partitionWhile
in interfaceMutableSortedMap<K,V>
- Specified by:
partitionWhile
in interfaceOrderedIterable<K>
- Specified by:
partitionWhile
in interfaceReversibleIterable<K>
- Specified by:
partitionWhile
in interfaceSortedMapIterable<K,V>
-
distinct
Description copied from interface:OrderedIterable
Returns a newOrderedIterable
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.- Specified by:
distinct
in interfaceMutableSortedMap<K,V>
- Specified by:
distinct
in interfaceOrderedIterable<K>
- Specified by:
distinct
in interfaceReversibleIterable<K>
- Specified by:
distinct
in interfaceSortedMapIterable<K,V>
- Returns:
OrderedIterable
of distinct elements
-
toString
Description copied from class:AbstractRichIterable
Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.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());
- Specified by:
toString
in interfaceMapIterable<K,V>
- Specified by:
toString
in interfaceRichIterable<K>
- Overrides:
toString
in classAbstractRichIterable<V>
- Returns:
- a string representation of this collection.
- See Also:
AbstractCollection.toString()
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-