Class ImmutableTreeMap<K,V>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<V>
org.eclipse.collections.impl.map.AbstractMapIterable<K,V>
org.eclipse.collections.impl.map.sorted.immutable.AbstractImmutableSortedMap<K,V>
org.eclipse.collections.impl.map.sorted.immutable.ImmutableTreeMap<K,V>
- All Implemented Interfaces:
Serializable
,Iterable<V>
,Map<K,V>
,SortedMap<K,V>
,InternalIterable<V>
,ImmutableMapIterable<K,V>
,MapIterable<K,V>
,ImmutableSortedMap<K,V>
,SortedMapIterable<K,V>
,OrderedIterable<V>
,ReversibleIterable<V>
,RichIterable<V>
public class ImmutableTreeMap<K,V> extends AbstractImmutableSortedMap<K,V> implements Serializable
- See Also:
ImmutableSortedMap
, Serialized Form
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description ImmutableTreeMap(SortedMap<K,V> sortedMap)
-
Method Summary
Modifier and Type Method Description Comparator<? super K>
comparator()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
ImmutableSortedMap<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.Set<Map.Entry<K,V>>
entrySet()
boolean
equals(Object object)
Follows the same general contract asMap.equals(Object)
.K
firstKey()
ImmutableMap<V,K>
flipUniqueValues()
Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key.void
forEachKeyValue(Procedure2<? super K,? super V> procedure)
Calls theprocedure
with each key-value pair of the map.V
get(Object key)
int
hashCode()
Follows the same general contract asMap.hashCode()
.Set<K>
keySet()
RichIterable<K>
keysView()
Returns an unmodifiable lazy iterable wrapped around the keySet for the map.RichIterable<Pair<K,V>>
keyValuesView()
Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.K
lastKey()
static <K, V> ImmutableSortedMap<K,V>
newMap(SortedMap<K,V> sortedMap)
int
size()
Returns the number of items in this iterable.ImmutableSortedMap<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.String
toString()
Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.Collection<V>
values()
RichIterable<V>
valuesView()
Returns an unmodifiable lazy iterable wrapped around the values for the map.Methods inherited from class org.eclipse.collections.impl.map.sorted.immutable.AbstractImmutableSortedMap
aggregateBy, aggregateInPlaceBy, asReversed, castToMap, castToSortedMap, clear, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, corresponds, countBy, countByEach, countByWith, detect, detectIndex, detectLastIndex, detectOptional, distinct, dropWhile, flatCollect, flip, forEach, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, headMap, indexOf, iterator, newWithAllKeyValueArguments, newWithAllKeyValues, newWithKeyValue, newWithoutAllKeys, newWithoutKey, partition, partitionWhile, partitionWith, put, putAll, reject, reject, rejectWith, remove, select, select, selectInstancesOf, selectWith, subMap, sumByDouble, sumByFloat, sumByInt, sumByLong, tailMap, takeWhile, tap, toImmutable, toReversed, toSortedMap, toStack, zip, zipWithIndex
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 org.eclipse.collections.api.map.sorted.ImmutableSortedMap
aggregateBy, collectWithIndex, flatCollectWith
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
forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getOrDefault, ifPresentApply, parallelStream, spliterator, stream
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
-
Method Details
-
newMap
-
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()
. -
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()
-
size
public int size()Description copied from interface:RichIterable
Returns the number of items in this iterable. -
containsKey
- Specified by:
containsKey
in interfaceMap<K,V>
- Specified by:
containsKey
in interfaceMapIterable<K,V>
- See Also:
Map.containsKey(Object)
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,V>
- Specified by:
containsValue
in interfaceMapIterable<K,V>
- See Also:
Map.containsValue(Object)
-
get
- Specified by:
get
in interfaceMap<K,V>
- Specified by:
get
in interfaceMapIterable<K,V>
- See Also:
Map.get(Object)
-
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>
-
flipUniqueValues
Description copied from interface:MapIterable
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)));
- Specified by:
flipUniqueValues
in interfaceImmutableMapIterable<K,V>
- Specified by:
flipUniqueValues
in interfaceMapIterable<K,V>
-
keysView
Description copied from interface:MapIterable
Returns an unmodifiable lazy iterable wrapped around the keySet for the map.- Specified by:
keysView
in interfaceMapIterable<K,V>
-
valuesView
Description copied from interface:MapIterable
Returns an unmodifiable lazy iterable wrapped around the values for the map.- Specified by:
valuesView
in interfaceMapIterable<K,V>
-
keyValuesView
Description copied from interface:MapIterable
Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.- Specified by:
keyValuesView
in interfaceMapIterable<K,V>
-
comparator
- Specified by:
comparator
in interfaceSortedMap<K,V>
- Specified by:
comparator
in interfaceSortedMapIterable<K,V>
-
firstKey
-
lastKey
-
keySet
-
values
-
entrySet
-
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 interfaceReversibleIterable<K>
- Specified by:
take
in interfaceSortedMapIterable<K,V>
- Parameters:
count
- the number of items to take.
-
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 interfaceReversibleIterable<K>
- Specified by:
drop
in interfaceSortedMapIterable<K,V>
- Parameters:
count
- the number of items to drop.
-