Class TreeMap<K,V>
java.lang.Object
com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable<Pair<K,V>>
com.github.andrewoma.dexx.collection.internal.base.AbstractIterable<Pair<K,V>>
com.github.andrewoma.dexx.collection.internal.base.AbstractMap<K,V>
com.github.andrewoma.dexx.collection.internal.base.AbstractSortedMap<K,V>
com.github.andrewoma.dexx.collection.TreeMap<K,V>
- All Implemented Interfaces:
Iterable<Pair<K,V>>, Map<K, V>, SortedMap<K, V>, Traversable<Pair<K, V>>, Iterable<Pair<K, V>>
TreeMap is an implementation of SortedMap based on a
red-black tree.
TreeMaps can be constructed with a KeyFunction
to provide modest memory saving per node. See DerivedKeyHashMap
for an example of using a key function.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionTreeMap()privateTreeMap(Comparator<? super K> ordering, KeyFunction<K, V> keyFunction) -
Method Summary
Modifier and TypeMethodDescriptionComparator<? super K> Returns the comparator associated with this map, ornullif the default ordering is used.booleancontainsKey(K key) Returns true if this map contains the specified key.drop(int number) Returns a map containing all elements in this map, excluding the firstnumberof elements.static <K,V> @NotNull BuilderFactory <Pair<K, V>, TreeMap<K, V>> factory(Comparator<? super K> ordering, KeyFunction<K, V> keyFunction) first()Returns the first entry in the map ornullif the map is empty.<U> voidAll collection methods can be built upon thisforEachdefinition.Returns the bottom of the map starting from the key specified.Returns the value associated with the key ornullif the no value exists with the key specified.booleanisEmpty()Returns true if this collection is empty.iterator()keys()Returns the keys for this map.last()Returns the last entry in the map ornullif the map is empty.Returns a map with the value specified associated to the key specified.Returns a subset of the map between thefromandtokeys specified.Returns a map with the value associated with the key removed if it exists.intsize()Returns the size of the collection.slice(int from, int until) take(int number) Returns a list containing the firstnumberof elements from this list.Returns the top of the map up until the key specified.values()Returns the values for this map.Methods inherited from class AbstractSortedMap
asSortedMapMethods inherited from class AbstractMap
asMap, equals, hashCodeMethods inherited from class AbstractTraversable
makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Traversable
makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
Field Details
-
tree
-
redBlackTree
-
-
Constructor Details
-
TreeMap
public TreeMap() -
TreeMap
-
TreeMap
-
-
Method Details
-
factory
@NotNull public static <K,V> @NotNull BuilderFactory<Pair<K,V>, TreeMap<K, factoryV>> (Comparator<? super K> ordering, KeyFunction<K, V> keyFunction) -
comparator
Description copied from interface:SortedMapReturns the comparator associated with this map, ornullif the default ordering is used. -
containsKey
-
put
-
get
-
size
public int size()Description copied from interface:TraversableReturns the size of the collection.Warning: infinite collections are possible, as are collections that require traversal to calculate the size.
- Specified by:
sizein interfaceTraversable<K>- Overrides:
sizein classAbstractTraversable<Pair<K,V>>
-
isEmpty
public boolean isEmpty()Description copied from interface:TraversableReturns true if this collection is empty.- Specified by:
isEmptyin interfaceTraversable<K>- Overrides:
isEmptyin classAbstractTraversable<Pair<K,V>>
-
remove
-
iterator
-
forEach
Description copied from interface:TraversableAll collection methods can be built upon thisforEachdefinition.- Specified by:
forEachin interfaceTraversable<K>- Overrides:
forEachin classAbstractIterable<Pair<K,V>>
-
first
-
toPair
-
last
-
drop
-
take
-
from
Description copied from interface:SortedMapReturns the bottom of the map starting from the key specified. -
to
Description copied from interface:SortedMapReturns the top of the map up until the key specified. -
range
@NotNull public @NotNull SortedMap<K,V> range(@NotNull K from, boolean fromInclusive, @NotNull K to, boolean toInclusive) Description copied from interface:SortedMapReturns a subset of the map between thefromandtokeys specified.- Parameters:
fromInclusive- if true, the key will be included in the result, otherwise it will be excludedtoInclusive- if true, the key will be included in the result, otherwise it will be excluded
-
keys
-
values
-
slice
-