public class TreeSortedMap<K,V> extends AbstractMutableSortedMap<K,V> implements Externalizable
Constructor and 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(Pair<K,V>... pairs) |
TreeSortedMap(SortedMap<K,? extends V> map) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
TreeSortedMap<K,V> |
clone() |
Comparator<? super K> |
comparator() |
boolean |
containsKey(Object key) |
boolean |
containsValue(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<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(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(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(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 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.
|
String |
toString()
Returns a string representation of this collection.
|
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) |
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, indexOf, partition, partitionWith, reject, reject, rejectWith, reverseForEach, select, select, selectInstancesOf, selectWith, tap, toImmutable, toStack, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndex
add, aggregateBy, aggregateInPlaceBy, collect, detect, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, groupByUniqueKey, iterator, keysView, keyValuesView, updateValue, updateValueWith, valuesView
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectWith, detectWithIfNone, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArray
appendString, 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, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
aggregateBy, aggregateInPlaceBy, collect, getIfAbsentPutWith, groupByUniqueKey
add, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWithKey, updateValue, updateValueWith
detect, forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, keysView, keyValuesView, valuesView
forEachWithIndex, getFirst, getLast, 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, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, maxBy, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy
forEach, forEachWith
forEach, iterator, spliterator
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll
public TreeSortedMap()
public TreeSortedMap(Comparator<? super K> comparator)
public TreeSortedMap(Comparator<? super K> comparator, Map<? extends K,? extends V> map)
public static <K,V> TreeSortedMap<K,V> newMap()
public static <K,V> TreeSortedMap<K,V> newMap(Comparator<? super K> comparator)
public static <K,V> TreeSortedMap<K,V> newMap(Map<? extends K,? extends V> map)
public static <K,V> TreeSortedMap<K,V> newMap(Comparator<? super K> comparator, 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(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(Comparator<? super K> comparator, K key, V value)
public static <K,V> TreeSortedMap<K,V> newMapWith(Comparator<? super K> comparator, K key1, V value1, K key2, V value2)
public static <K,V> TreeSortedMap<K,V> newMapWith(Comparator<? super K> comparator, K key1, V value1, K key2, V value2, K key3, V value3)
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)
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>
with
in class AbstractMutableSortedMap<K,V>
public int size()
RichIterable
public MutableSortedMap<K,V> newEmpty()
MutableSortedMap
newEmpty
in interface MutableMapIterable<K,V>
newEmpty
in interface MutableSortedMap<K,V>
public V removeKey(K key)
MutableMapIterable
key
.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(Object o)
MapIterable
Map.equals(Object)
.public int hashCode()
MapIterable
Map.hashCode()
.public void forEachKeyValue(Procedure2<? super K,? super V> procedure2)
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(new Procedure2<Integer, String>() { public void value(final Integer key, final String value) { collection.add(String.valueOf(key) + value); } }); Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
forEachKeyValue
in interface MapIterable<K,V>
public MutableSet<Map.Entry<K,V>> entrySet()
public MutableSet<K> keySet()
MutableSortedMap
public MutableCollection<V> values()
public Comparator<? super K> comparator()
comparator
in interface SortedMap<K,V>
comparator
in interface SortedMapIterable<K,V>
public V get(Object key)
get
in interface Map<K,V>
get
in interface MapIterable<K,V>
Map.get(Object)
public boolean containsKey(Object key)
containsKey
in interface 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(Object value)
containsValue
in interface Map<K,V>
containsValue
in interface MapIterable<K,V>
Map.containsValue(Object)
public MutableSortedMap<K,V> toReversed()
ReversibleIterable
toReversed
in interface MutableSortedMap<K,V>
toReversed
in interface SortedMapIterable<K,V>
toReversed
in interface ReversibleIterable<V>
public MutableSortedMap<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 MutableSortedMap<K,V>
take
in interface SortedMapIterable<K,V>
take
in interface ReversibleIterable<V>
count
- the number of items to take.public MutableSortedMap<K,V> takeWhile(Predicate<? super V> predicate)
ReversibleIterable
takeWhile
in interface MutableSortedMap<K,V>
takeWhile
in interface SortedMapIterable<K,V>
takeWhile
in interface OrderedIterable<V>
takeWhile
in interface ReversibleIterable<V>
public MutableSortedMap<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 MutableSortedMap<K,V>
drop
in interface SortedMapIterable<K,V>
drop
in interface ReversibleIterable<V>
count
- the number of items to drop.public MutableSortedMap<K,V> dropWhile(Predicate<? super V> predicate)
ReversibleIterable
dropWhile
in interface MutableSortedMap<K,V>
dropWhile
in interface SortedMapIterable<K,V>
dropWhile
in interface OrderedIterable<V>
dropWhile
in interface ReversibleIterable<V>
public PartitionMutableList<V> partitionWhile(Predicate<? super V> predicate)
OrderedIterable
partitionWhile
in interface MutableSortedMap<K,V>
partitionWhile
in interface SortedMapIterable<K,V>
partitionWhile
in interface OrderedIterable<V>
partitionWhile
in interface ReversibleIterable<V>
public MutableList<V> distinct()
OrderedIterable
OrderedIterable
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 SortedMapIterable<K,V>
distinct
in interface OrderedIterable<V>
distinct
in interface ReversibleIterable<V>
OrderedIterable
of distinct elementspublic String toString()
AbstractRichIterable
This implementation creates an empty string buffer, appends a left square bracket, and iterates over the collection appending the string representation of each element in turn. After appending each element except the last, the string ", " is appended. Finally a right bracket is appended. A string is obtained from the string buffer, and returned.
toString
in interface MapIterable<K,V>
toString
in interface RichIterable<V>
toString
in class AbstractRichIterable<V>
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
Copyright © 2004–2016. All rights reserved.