Package com.github.tadukoo.util.map
Class TreeMultiMap<K,V>
java.lang.Object
com.github.tadukoo.util.map.MultiMap<K,V>
com.github.tadukoo.util.map.TreeMultiMap<K,V>
- Since:
- Alpha v.0.1
- Version:
- Alpha v.0.2
- Author:
- Logan Ferree (Tadukoo)
-
Constructor Summary
ConstructorDescriptionCreates a new TreeMultiMap where the backingTreeMap
uses the natural ordering of its keys.TreeMultiMap
(MultiMap<K, V> multiMap) Creates a new TreeMultiMap where the backingTreeMap
uses the givenComparator
to determine the ordering of its keys.TreeMultiMap
(TreeMultiMap<K, V> treeMultiMap) Creates a new TreeMultiMap where the backingTreeMap
uses theComparator
present in the given TreeMultiMap to determine the ordering of its keys.TreeMultiMap
(Pair<K, V>... entries) Creates a new TreeMultiMap where the given Pairs are loaded into the map right away.TreeMultiMap
(Comparator<? super K> comparator) Creates a new TreeMultiMap where the backingTreeMap
uses the givenComparator
to determine the ordering of its keys.TreeMultiMap
(Map<K, V> map) TreeMultiMap
(SortedMap<K, V> map) -
Method Summary
Modifier and TypeMethodDescriptionasMap()
Returns the underlyingTreeMap
of this TreeMultiMap.ceilingEntry
(K key) Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.ceilingKey
(K key) Returns the least key greater than or equal to the given key, or null if there is no such key.Comparator<? super K>
NavigableMap<K,
List<V>> firstKey()
floorEntry
(K key) Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.Returns the greatest key less than or equal to the given key, or null if there is no such key.NavigableMap<K,
List<V>> higherEntry
(K key) Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.Returns the least key strictly greater than the given key, or null if there is no such key.lastKey()
lowerEntry
(K key) Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.Returns the greatest key strictly less than the given key, or null if there is no such key.Removes and returns a key-value mapping associated with the least key in this multiMap, or null if the multiMap is empty.Removes and returns a key-value mapping associated with the greatest key in this multiMap, or null if the multiMap is empty.NavigableMap<K,
List<V>> NavigableMap<K,
List<V>> Methods inherited from class com.github.tadukoo.util.map.MultiMap
clear, containsKey, containsValue, equals, forEach, get, isEmpty, keySet, keySetSize, put, putAll, putAll, putAll, putAll, remove, removeEntireList, removeKey, replace, replaceEntireList, replaceEntireList, size, values
-
Constructor Details
-
TreeMultiMap
public TreeMultiMap()Creates a new TreeMultiMap where the backingTreeMap
uses the natural ordering of its keys. -
TreeMultiMap
Creates a new TreeMultiMap where the backingTreeMap
uses the givenComparator
to determine the ordering of its keys.- Parameters:
comparator
- The Comparator to use in ordering the keys
-
TreeMultiMap
Creates a new TreeMultiMap where the given Pairs are loaded into the map right away.- Parameters:
entries
- The Pairs to be placed in this MultiMap
-
TreeMultiMap
Creates a new TreeMultiMap where the backingTreeMap
is constructed with the same mappings as the specifiedMap
. The backing TreeMap uses the natural ordering of its keys.- Parameters:
map
- The Map whose mappings are to be placed in the backing TreeMap
-
TreeMultiMap
Creates a new TreeMultiMap where the backingTreeMap
is constructed with the same mappings as the specifiedSortedMap
. The backing TreeMap also uses theComparator
used by the given SortedMap.- Parameters:
map
- The SortedMap whose mappings are to be placed in the backing TreeMap
-
TreeMultiMap
Creates a new TreeMultiMap where the backingTreeMap
uses the givenComparator
to determine the ordering of its keys.
The MultiMap is then populated with the values present in the specifiedMultiMap
.- Parameters:
multiMap
- The MultiMap whose mappings are to be placed in this MultiMap
-
TreeMultiMap
Creates a new TreeMultiMap where the backingTreeMap
uses theComparator
present in the given TreeMultiMap to determine the ordering of its keys.
The MultiMap is then populated with the values present in the specified TreeMultiMap.- Parameters:
treeMultiMap
- The TreeMultiMap whose mappings are to be placed in this MultiMap
-
-
Method Details
-
asMap
Returns the underlyingTreeMap
of this TreeMultiMap. -
comparator
- Returns:
- The
Comparator
used by this TreeMultiMap
-
firstKey
- Returns:
- The first (lowest) key in this multiMap
-
lastKey
- Returns:
- The last (highest) key in this multiMap
-
firstEntry
- Returns:
- A key-value mapping associated with the least key in this multiMap, or null if the multiMap is empty
-
lastEntry
- Returns:
- A key-value mapping associated with the greatest key in this map, or null if the multiMap is empty
-
pollFirstEntry
Removes and returns a key-value mapping associated with the least key in this multiMap, or null if the multiMap is empty.- Returns:
- The removed first entry of this multiMap, or null if it's empty
-
pollLastEntry
Removes and returns a key-value mapping associated with the greatest key in this multiMap, or null if the multiMap is empty.- Returns:
- The removed last entry of this multiMap, or null if it's empty
-
lowerKey
Returns the greatest key strictly less than the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- The greatest key less than key, or null if there is no such key
-
higherKey
Returns the least key strictly greater than the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- The least key greater than key, or null if there is no such key
-
lowerEntry
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- An entry with the greatest key less than key, or null if there is no such key
-
higherEntry
Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- An entry with the least key greater than key, or null if there is no such key
-
floorKey
Returns the greatest key less than or equal to the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- The greatest key less than or equal to key, or null if there is no such key
-
ceilingKey
Returns the least key greater than or equal to the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- The least key greater than or equal to key, or null if there is no such key
-
floorEntry
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- An entry with the greatest key less than or equal to key, or null if there is no such key
-
ceilingEntry
Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.- Parameters:
key
- The key- Returns:
- An entry with the least key greater than or equal to key, or null if there is no such key
-
descendingKeySet
- Returns:
- A reverse order navigable set view of the keys in this multiMap
- See Also:
-
descendingMap
- Returns:
- A reverse order view of this multiMap
- See Also:
-
subMap
- Parameters:
fromKey
- low end point (inclusive) of the keys in the returned maptoKey
- high end point (exclusive) of the keys in the returned map- Returns:
- A view of the portion of this multiMap whose keys range from fromKey, inclusive, to toKey, exclusive
- See Also:
-
subMap
public NavigableMap<K,List<V>> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) - Parameters:
fromKey
- low end point of the keys in the returned mapfromInclusive
- true if the low end point is to be included in the returned viewtoKey
- high end point of the keys in the returned maptoInclusive
- true if the high end point is to be included in the returned view- Returns:
- A view of the portion of this map whose keys range from fromKey to toKey
- See Also:
-
headMap
- Parameters:
toKey
- high end point (exclusive) of the keys in the returned map- Returns:
- A view of the portion of this multiMap whose keys are strictly less than toKey
- See Also:
-
headMap
- Parameters:
toKey
- high end point of the keys in the returned mapinclusive
- true if the high end point is to be included in the returned view- Returns:
- A view of the portion of this multiMap whose keys are less than (or equal to, if inclusive is true) toKey
- See Also:
-
tailMap
- Parameters:
fromKey
- low end point (inclusive) of the keys in the returned map- Returns:
- A view of the portion of this multiMap whose keys are greater than or equal to fromKey
- See Also:
-
tailMap
- Parameters:
fromKey
- low end point of the keys in the returned mapinclusive
- true if the low end point is to be included in the returned view- Returns:
- A view of the portion of this multiMap whose keys are greater than (or equal to, if inclusive is true) fromKey
- See Also:
-