Package com.github.tadukoo.util.map
Class TreeManyToManyMap<K,V>
java.lang.Object
com.github.tadukoo.util.map.ManyToManyMap<K,V>
com.github.tadukoo.util.map.TreeManyToManyMap<K,V>
A ManyToManyMap class that uses
TreeMultiMap
as the backing MultiMap
class.- Since:
- Alpha v.0.1
- Version:
- Alpha v.0.2
- Author:
- Logan Ferree (Tadukoo)
-
Constructor Summary
ConstructorDescriptionCreates a new HashManyToManyMap where the backing TreeManyToManyMap uses the natural ordering of its keys.TreeManyToManyMap
(ManyToManyMap<K, V> manyToManyMap) Creates a new TreeManyToManyMap where the backing TreeMultiMap uses the natural ordering of its keys.TreeManyToManyMap
(MultiMap<K, V> multiMap) Creates a new TreeManyToManyMap where the backingTreeMultiMap
uses the givenComparator
to determine the ordering of its keys.TreeManyToManyMap
(Pair<K, V>... entries) Creates a new TreeManyToManyMap where the given Pairs are loaded into the map right away.TreeManyToManyMap
(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) Creates a new TreeManyToManyMap where the backingTreeMultiMap
uses the givenComparator
s to determine the ordering of its keys and values.TreeManyToManyMap
(Map<K, V> map) Creates a new TreeManyToManyMap where the backingTreeMultiMap
is constructed with the same mappings as the specifiedMap
.TreeManyToManyMap
(SortedMap<K, V> map) Creates a new TreeManyToManyMap where the backingTreeMultiMap
is constructed with the same mappings as the specifiedSortedMap
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlying TreeMultiMap used for keys to values.Returns the underlying TreeMultiMap used for values to keys.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.NavigableMap<K,
List<V>> boolean
Compares the given object with this TreeManyToManyMap for equality.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.Comparator<? super K>
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 manyToManyMap, or null if the manyToManyMap is empty.Removes and returns a key-value mapping associated with the greatest key in this manyToManyMap, or null if the manyToManyMap is empty.NavigableMap<K,
List<V>> NavigableMap<K,
List<V>> Comparator<? super V>
Methods inherited from class com.github.tadukoo.util.map.ManyToManyMap
clear, containsKey, containsValue, forEach, getKeys, getValues, isEmpty, keySet, keySetSize, keysToValues, put, putAllKeys, putAllKeyValMappings, putAllKeyValMappings, putAllKeyValMappings, putAllKeyValMappings, putAllValKeyMappings, putAllValKeyMappings, putAllValKeyMappings, putAllValKeyMappings, putAllValues, remove, removeEntireKeysList, removeEntireValuesList, removeKey, removeValue, replaceEntireKeyList, replaceEntireKeyList, replaceEntireValueList, replaceEntireValueList, replaceKey, replaceValue, size, valueSet, valueSetSize, valuesToKeys
-
Constructor Details
-
TreeManyToManyMap
public TreeManyToManyMap()Creates a new HashManyToManyMap where the backing TreeManyToManyMap uses the natural ordering of its keys. -
TreeManyToManyMap
public TreeManyToManyMap(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) Creates a new TreeManyToManyMap where the backingTreeMultiMap
uses the givenComparator
s to determine the ordering of its keys and values.- Parameters:
keyComparator
- The Comparator to use in ordering the keysvalueComparator
- The Comparator to use in ordering the values
-
TreeManyToManyMap
Creates a new TreeManyToManyMap where the given Pairs are loaded into the map right away.- Parameters:
entries
- A collection of key-value Pairs to be put in this ManyToManyMap
-
TreeManyToManyMap
Creates a new TreeManyToManyMap where the backingTreeMultiMap
is constructed with the same mappings as the specifiedMap
. The backing TreeMultiMap uses the natural ordering of its keys.- Parameters:
map
- The Map whose mappings are to be placed in the backing TreeMultiMap
-
TreeManyToManyMap
Creates a new TreeManyToManyMap where the backingTreeMultiMap
is constructed with the same mappings as the specifiedSortedMap
. The backing TreeMultiMap also uses theComparator
used by the given SortedMap.- Parameters:
map
- The SortedMap whose mappings are to be placed in the backing TreeMultiMap
-
TreeManyToManyMap
Creates a new TreeManyToManyMap where the backingTreeMultiMap
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
-
TreeManyToManyMap
Creates a new TreeManyToManyMap where the backing TreeMultiMap uses the natural ordering of its keys.
The ManyToManyMap is then populated with the values present in the specified ManyToManyMap.- Parameters:
manyToManyMap
- The ManyToManyMap whose mappings are to be placed in this ManyToManyMap
-
-
Method Details
-
equals
Compares the given object with this TreeManyToManyMap for equality. Returns true if the given object is also a TreeManyToManyMap and the two TreeManyToManyMaps represent the same mappings. If they're both TreeManyToManyMaps, it will runManyToManyMap.equals(java.lang.Object)
to compare them.- Overrides:
equals
in classManyToManyMap<K,
V> - Parameters:
o
- The object to be compared for equality with this TreeManyToManyMap- Returns:
- true if the given object is equivalent to this TreeManyToManyMap
-
keyComparator
- Returns:
- The keys
Comparator
used by the keysToValues TreeMultiMap
-
valueComparator
- Returns:
- The values
Comparator
used by the valuesToKeys TreeMultiMap
-
asKeysToValuesMultiMap
Returns the underlying TreeMultiMap used for keys to values.- Returns:
- The underlying TreeMultiMap of keys to values
-
asValuesToKeysMultiMap
Returns the underlying TreeMultiMap used for values to keys.- Returns:
- The underlying TreeMultiMap of values to keys
-
firstKey
- Returns:
- The first (lowest) key in this manyToManyMap
-
lastKey
- Returns:
- The last (highest) key in this manyToManyMap
-
firstEntry
- Returns:
- A key-value mapping associated with the least key in this manyToManyMap, or null if the manyToManyMap is empty
-
lastEntry
- Returns:
- A key-value mapping associated with the greatest key in this map, or null if the manyToManyMap is empty
-
pollFirstEntry
Removes and returns a key-value mapping associated with the least key in this manyToManyMap, or null if the manyToManyMap is empty.- Returns:
- The removed first entry of this manyToManyMap, or null if it's empty
-
pollLastEntry
Removes and returns a key-value mapping associated with the greatest key in this manyToManyMap, or null if the manyToManyMap is empty.- Returns:
- The removed last entry of this manyToManyMap, 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 manyToManyMap
- See Also:
-
descendingMap
- Returns:
- R reverse order view of this manyToManyMap
- 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 manyToManyMap 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 manyToManyMap 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 manyToManyMap 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 manyToManyMap 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 manyToManyMap whose keys are greater than (or equal to, if inclusive is true) fromKey
- See Also:
-