Package org.midheaven.collections
Interface Association<K,V>
- Type Parameters:
K- the type of the KeyV- the type of the Value
- All Superinterfaces:
Assortment<Association.Entry<K,,V>> Countable,Enumerable<Association.Entry<K,,V>> Iterable<Association.Entry<K,V>>
- All Known Subinterfaces:
EditableAssociation<K,,V> ResizableAssociation<K,V>
An
Assortment of Association.Entry<K,V> that allows for retrieval of the values associated with the keys.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AssociationBuilderbuilder().computeValueIfAbsent(K key, Function<K, V> computation) If the value is found return it.booleancontainsKey(Object key) Determines if thisAssociationcontains the given keybooleancontainsValue(Object value) Determines if thisAssociationcontains the given keyReturns get Value.intersection(Association<K, V> other, BiFunction<V, V, V> valueSelector) Creates the intersection of this association with another.keys()Returns keys.default Set<Association.Entry<K, V>> Returns to Collection.union(Association<K, V> other, BiFunction<V, V, V> valueSelector) Creates the union of this association with another.values()Returns values.Methods inherited from interface org.midheaven.collections.Assortment
contains, containsAll, count, isEmptyMethods inherited from interface org.midheaven.collections.Enumerable
allMatch, any, anyMatch, as, associate, associate, cast, collect, concat, distinct, enumerator, filter, first, flatMap, groupBy, iterator, limit, map, maximum, minimum, ofType, peek, reduce, reduce, skip, sorted, toArray, toArray, toArray, toDistinctAssortment, toSequence, toSequence, with, zipMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
builder
.- Returns:
- the builder
-
containsKey
Determines if thisAssociationcontains the given key- Parameters:
key- the key to test- Returns:
trueif the key is contained in theAssociation,falseotherwise.
-
containsValue
Determines if thisAssociationcontains the given key- Parameters:
value- the value to test- Returns:
trueif the key is contained in theAssociation,falseotherwise.
-
union
Creates the union of this association with another. If the same key is found in both the functionvalueSelectoris called to determine the result of the union.- Parameters:
other- the other association to union with.valueSelector- an operation to select the result of the union of two values- Returns:
- a new
Associationwith the union of the keys of the originalAssociations
-
intersection
Creates the intersection of this association with another. When the same key is found in both the functionvalueSelectoris called to determine the result of the union.- Parameters:
other- the other association to intersect with.valueSelector- an operation to select the result of the union of two values- Returns:
- a new
Associationwith the common keys in the originalAssociations
-
computeValueIfAbsent
If the value is found return it. If not, compute a value from the key. The computed value is not permanently associated with the key.- Parameters:
key-computation-- Returns:
-
keys
DistinctAssortment<K> keys()Returns keys.- Returns:
- the result of keys
-
values
Assortment<V> values()Returns values.- Returns:
- the result of values
-
getValue
Returns get Value.- Parameters:
key- the key value- Returns:
- the result of getValue
-
toCollection
Returns to Collection.- Specified by:
toCollectionin interfaceAssortment<K>- Returns:
- the result of toCollection
-