Package org.jppf.utils.collections
Interface CollectionMap<K,V>
- Type Parameters:
K- the type of keys in the map.V- the type of values in the collections mapped to the keys.
- All Superinterfaces:
Iterable<V>,Serializable
- All Known Subinterfaces:
CollectionSortedMap<K,V>
- All Known Implementing Classes:
AbstractCollectionConcurrentMap,AbstractCollectionHashtable,AbstractCollectionMap,AbstractCollectionSortedMap,ArrayListHashMap,ArrayListSortedMap,CopyOnWriteListConcurrentMap,EnumSetEnumMap,LinkedListHashMap,LinkedListSortedMap,SetHashMap,SetIdentityMap,SetSortedMap,SortedSetSortedMap,SynchronizedLinkedListConcurrentMap,VectorHashtable
Interface for maps whose values are collections of a given component type.
- Author:
- Laurent Cohen
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddValues(K key, Collection<V> values) Add the specified values to the specified key.voidAdd the specified values to the specified key.Get a collection of all the values for all keys.voidclear()Clear the map.booleancontainsKey(K key) Determine whether this map contains the specified key.booleancontainsValue(K key, V value) Determine whether the collection mapped to the specified key contains the specified value.booleancontainsValue(V value) Determine whether at least one of the collections in the map contains the specified value.Set<Map.Entry<K,Collection<V>>> entrySet()Get the set map entries.default voidforEach(BiConsumer<K, Collection<V>> consumer) DefaultforEachimplementation.Get the collection of values maped to the specified key.booleanisEmpty()Determine whether this map is empty.Get an iterator which uses the specified lock.keySet()Get the set of keys in the map.voidAdd a value for the specified key.Remove the specified key from this map.booleanremoveValue(K key, V value) Remove a value from the specified key.intremoveValues(K key, V... values) Remove the specified values from the specified key.intsize()Get the total number of elements in this collection map.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
putValue
Add a value for the specified key.- Parameters:
key- the key for which to add a value.value- the value to add.
-
removeValue
Remove a value from the specified key.- Parameters:
key- the key from which to remove a value.value- the value to remove.- Returns:
trueif an element was removed,falseotherwise.
-
addValues
Add the specified values to the specified key. This is a bulk operation.- Parameters:
key- the key to which to add the values.values- the values to add to the key.
-
addValues
Add the specified values to the specified key. This is a bulk operation.- Parameters:
key- the key to which to add the values.values- the values to add to the key.
-
removeValues
Remove the specified values from the specified key. This is a bulk operation.- Parameters:
key- the key for which to rmeove the values.values- the values to remove.- Returns:
- the number of values that were actually removed, possibly zero.
-
removeKey
Remove the specified key from this map.- Parameters:
key- the key to remove.- Returns:
- collection of values that were removed, possibly
null.
-
getValues
Get the collection of values maped to the specified key.- Parameters:
key- the key to lookup.- Returns:
- a collection of values that mapped to the key, or
nullif no mapping exists for the key.
-
size
int size()Get the total number of elements in this collection map. Note that the cost of thesize()operation will be in O(n).- Returns:
- the number of elements as an int value.
-
isEmpty
boolean isEmpty()Determine whether this map is empty.- Returns:
trueif the map is empty,falseotherwise.
-
containsKey
Determine whether this map contains the specified key.- Parameters:
key- the key to lookup.- Returns:
trueif there is a mapping for the key,falseotherwise.
-
containsValue
Determine whether the collection mapped to the specified key contains the specified value.- Parameters:
key- the key whose mapped collection is looked up^.value- the value to look in the collection.- Returns:
trueif the map contains the key and the corresponding collection contains the value,falseotehrwise.
-
containsValue
Determine whether at least one of the collections in the map contains the specified value.- Parameters:
value- the value to look up in the entire map.- Returns:
trueif the map contains the value,falseotehrwise.
-
iterator
Get an iterator which uses the specified lock.- Parameters:
lock- the lock used to synchronize access to the map.- Returns:
- an iterator on the values of the map.
-
keySet
Get the set of keys in the map.- Returns:
- a
Setof all keys.
-
entrySet
Set<Map.Entry<K,Collection<V>>> entrySet()Get the set map entries.- Returns:
- a
Setof all map entries.
-
clear
void clear()Clear the map. -
allValues
Get a collection of all the values for all keys.- Returns:
- a collection of all values in this map.
-
forEach
DefaultforEachimplementation.- Parameters:
consumer- theBiConsumerfunction.
-