java.io.Serializable
, java.lang.Iterable<K>
, InternalIterable<K>
, ImmutableMapIterable<K,V>
, MapIterable<K,V>
, ImmutableSortedMap<K,V>
, SortedMapIterable<K,V>
, OrderedIterable<K>
, ReversibleIterable<K>
, RichIterable<K>
public class ImmutableTreeMap<K,V> extends AbstractImmutableSortedMap<K,V> implements java.io.Serializable
ImmutableSortedMap
,
Serialized FormConstructor | Description |
---|---|
ImmutableTreeMap(java.util.SortedMap<K,V> sortedMap) |
Modifier and Type | Method | Description |
---|---|---|
java.util.Comparator<? super K> |
comparator() |
|
boolean |
containsKey(java.lang.Object key) |
|
boolean |
containsValue(java.lang.Object value) |
|
ImmutableSortedMap<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. |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
|
boolean |
equals(java.lang.Object object) |
Follows the same general contract as
Map.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 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() . |
java.util.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(java.util.SortedMap<K,V> sortedMap) |
|
int |
size() |
Returns the number of items in this iterable.
|
ImmutableSortedMap<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. |
java.lang.String |
toString() |
Returns a string with the elements of the iterable separated by commas with spaces and
enclosed in square brackets.
|
java.util.Collection<V> |
values() |
|
RichIterable<V> |
valuesView() |
Returns an unmodifiable lazy iterable wrapped around the values for the map.
|
aggregateBy, aggregateInPlaceBy, asReversed, castToMap, castToSortedMap, clear, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, corresponds, countBy, 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, reverseForEach, reverseForEachWithIndex, select, select, selectInstancesOf, selectWith, subMap, sumByDouble, sumByFloat, sumByInt, sumByLong, tailMap, takeWhile, tap, toImmutable, toReversed, toSortedMap, toStack, zip, zipWithIndex
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, toArray
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, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
collectWithIndex, flatCollectWith
forEach, forEach, forEachWith
compute, computeIfAbsent, computeIfPresent, entry, forEach, getOrDefault, isEmpty, merge, of, of, of, of, of, of, of, of, of, of, of, ofEntries, putIfAbsent, remove, replace, replace, replaceAll
forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, parallelStream, spliterator, stream
collectWithIndex, forEachWithIndex, getFirst, getFirstOptional, getLast, getLastOptional, max, min, zip, zipWithIndex
allSatisfy, 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, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectWith, getOnly, groupBy, 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, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy
public static <K,V> ImmutableSortedMap<K,V> newMap(java.util.SortedMap<K,V> sortedMap)
public boolean equals(java.lang.Object object)
MapIterable
Map.equals(Object)
.equals
in interface MapIterable<K,V>
equals
in class java.lang.Object
public int hashCode()
MapIterable
Map.hashCode()
.hashCode
in interface MapIterable<K,V>
hashCode
in class java.lang.Object
public 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 int size()
RichIterable
size
in interface RichIterable<K>
public boolean containsKey(java.lang.Object key)
containsKey
in interface MapIterable<K,V>
Map.containsKey(Object)
public boolean containsValue(java.lang.Object value)
containsValue
in interface MapIterable<K,V>
Map.containsValue(Object)
public V get(java.lang.Object key)
get
in interface MapIterable<K,V>
Map.get(Object)
public void forEachKeyValue(Procedure2<? super K,? super V> procedure)
MapIterable
procedure
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 ImmutableMap<V,K> flipUniqueValues()
MapIterable
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)));
flipUniqueValues
in interface ImmutableMapIterable<K,V>
flipUniqueValues
in interface MapIterable<K,V>
public RichIterable<K> keysView()
MapIterable
keysView
in interface MapIterable<K,V>
public RichIterable<V> valuesView()
MapIterable
valuesView
in interface MapIterable<K,V>
public RichIterable<Pair<K,V>> keyValuesView()
MapIterable
keyValuesView
in interface MapIterable<K,V>
public java.util.Comparator<? super K> comparator()
comparator
in interface SortedMapIterable<K,V>
public K firstKey()
public K lastKey()
public java.util.Set<K> keySet()
public java.util.Collection<V> values()
public ImmutableSortedMap<K,V> take(int count)
ReversibleIterable
count
elements of the iterable
or all the elements in the iterable if count
is greater than the length of
the iterable.take
in interface ReversibleIterable<K>
take
in interface SortedMapIterable<K,V>
count
- the number of items to take.public ImmutableSortedMap<K,V> drop(int count)
ReversibleIterable
count
elements
or an empty iterable if the count
is greater than the length of the iterable.drop
in interface ReversibleIterable<K>
drop
in interface SortedMapIterable<K,V>
count
- the number of items to drop.Copyright © 2004–2018. All rights reserved.