Class TreeMultimap<K,V>
java.lang.Object
com.atlassian.bamboo.utils.collection.multimap.TreeMultimap<K,V>
- Type Parameters:
K- the type of keys maintained by this multimapV- the type of mapped values
- All Implemented Interfaces:
ImmutableMultimap<K,,V> Multimap<K,V>
A TreeMultimap is an implementation of a Multimap that uses a TreeMap to store keys in sorted order
according to a provided key comparator, and a TreeSet for the values associated with each key to maintain
their sorted order as per a provided value comparator. This structure allows for efficient data storage
and retrieval in a sorted manner.
If a key or value comparator is null, the order for it follows the order of addition.
You can mix a null key comparator with a not-null value one and vice versa.
- Since:
- 10.0
-
Constructor Summary
ConstructorsConstructorDescriptionTreeMultimap(@Nullable Comparator<? super K> keyComparator, @Nullable Comparator<? super V> valueComparator) -
Method Summary
Modifier and TypeMethodDescriptionMap<K, Collection<V>> asMap()Returns a view of the mappings contained in this multimap as a map from each key to its corresponding values.booleancontainsKey(K key) Returnstrueif this multimap contains one or more keys to the specified value.copy()Creates a deep copy of this multimap.static <K,V> TreeMultimap <K, V> create(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) entries()Returns a collection view of all key-value pairs contained in this multimap.booleanRetrieves the collection of values associated with the specified key in this multimap.inthashCode()inverse()Creates an inverse view of this multimap.booleanisEmpty()Returnstrueif this multimap contains no key-value mappings.keySet()Returns the set of keys contained in this multimap.voidAssociates the specified value with the specified key in this multimap.voidputAll(K key, Collection<? extends V> values) Associates all of the values in the specified collection with the specified key in this multimap.voidRemoves a single instance of the specified value from the multimap, if it is present.voidRemoves all the values associated with the specified key in this multimap.intsize()Returns the total number of key-value pairs in the multimap.values()Returns a collection view of all values associated with keys in this multimap.
-
Constructor Details
-
TreeMultimap
public TreeMultimap(@Nullable @Nullable Comparator<? super K> keyComparator, @Nullable @Nullable Comparator<? super V> valueComparator)
-
-
Method Details
-
create
public static <K,V> TreeMultimap<K,V> create(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator) -
put
Description copied from interface:MultimapAssociates the specified value with the specified key in this multimap. If the multimap previously contained a mapping for the key, the new value is added to the collection of values mapped to that key. -
putAll
Description copied from interface:MultimapAssociates all of the values in the specified collection with the specified key in this multimap. If the multimap previously contained mappings for the key, the new values are added to the collection of values mapped to that key. -
get
Description copied from interface:MultimapRetrieves the collection of values associated with the specified key in this multimap.- Specified by:
getin interfaceImmutableMultimap<K,V> - Specified by:
getin interfaceMultimap<K,V> - Parameters:
key- the key whose associated values are to be returned- Returns:
- the collection of values associated with the specified key, or an empty collection if no values are associated with the key
-
entries
Description copied from interface:MultimapReturns a collection view of all key-value pairs contained in this multimap. Each key-value pair is represented as a Map.Entry. If the multimap allows duplicate values, a separate Map.Entry will be included for each duplicate value. -
remove
Description copied from interface:MultimapRemoves a single instance of the specified value from the multimap, if it is present. -
removeAll
Description copied from interface:MultimapRemoves all the values associated with the specified key in this multimap. -
size
public int size()Description copied from interface:MultimapReturns the total number of key-value pairs in the multimap. -
isEmpty
public boolean isEmpty()Description copied from interface:MultimapReturnstrueif this multimap contains no key-value mappings. -
containsKey
Description copied from interface:MultimapReturnstrueif this multimap contains one or more keys to the specified value.- Specified by:
containsKeyin interfaceImmutableMultimap<K,V> - Specified by:
containsKeyin interfaceMultimap<K,V> - Parameters:
key- key whose presence in this multimap is to be tested- Returns:
trueif this multimap contains a mapping for the specified key
-
keySet
Description copied from interface:MultimapReturns the set of keys contained in this multimap. -
values
Description copied from interface:MultimapReturns a collection view of all values associated with keys in this multimap. -
asMap
Description copied from interface:MultimapReturns a view of the mappings contained in this multimap as a map from each key to its corresponding values. -
copy
Description copied from interface:MultimapCreates a deep copy of this multimap. -
inverse
Description copied from interface:MultimapCreates an inverse view of this multimap. In the inverse multimap, each value in the original multimap becomes a key in the new multimap, and each key in the original becomes part of the set of values associated with the new key. The inverse multimap is also immutable. -
equals
-
hashCode
public int hashCode()
-