Interface Multimap<A,B>
- All Superinterfaces:
BiPredicate<A,,B> Collection<Map.Entry<A,,B>> Iterable<Map.Entry<A,,B>> Set<Map.Entry<A,B>>
- All Known Subinterfaces:
Multimap_checkedLeft<L,,R> Multimap_checkedRight<L,,R> SortedMultimap<A,B>
- All Known Implementing Classes:
AbstractMultimap,CheckedMultimap_D,CheckedMultimap_R,CheckedMultimap_RD,ForwardMultimap,HashMultimap,IndexMultimap,MapMultimap,UnmodifiableMultimap
Map.Entry. The object returned by getKey() is called the left component
of the pair; the object returned by getValue() is called the right component of the
pair. null components are not supported.
The effect of attempting to change the right component by
invoking setValue on a pair is
unspecified. Implementations may either prohibit the operation by
throwing UnsupportedOperationException or allow the
operation but behave in an unspecified way afterwards.
Pairs in a multimap are considered equal if and only if both
their left and right components are equal according to their
respective equals methods. Such pairs are said to be equal
componentwise. The implementations of Map.Entry
returned by implementations must implement equals and
hashCode accordingly.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a pair to this multimap.booleanWhether this multimap contains a pair with the given components.booleancontainsUnchecked(Object a, Object b) domain()Returns the set of left components of pairs in this multimap.Returns the set of right components of pairs with a given left component in this multimap.imageAll(Collection<? extends A> a) Returns the set of right components of pairs in this multimap, which have a left component in the given set.imageAllUnchecked(Collection<?> a) imageMap()Returns a map which maps each A which appears as a left component to a set of all B which appear as its right component.Returns the set of left components of pairs with a given right component in this multimap.preimageAll(Collection<? extends B> b) Returns the set of left components of pairs in this multimap, which have a right component in the given set.Returns a map which maps each B which appears as a right component to a set of all A which appear as its left component.range()Returns the set of right components of pairs in this multimap.booleanRemoves a pair from this this multimap.booleanremoveAllDomain(Collection<? extends A> c) Removes all pairs with a left component in the given collection from this multimap.booleanbooleanremoveAllRange(Collection<? extends B> c) Removes all pairs with a right component in the given collection from this multimap.booleanbooleanremoveDomain(A a) Removes all pairs with a given left component from this multimap.booleanbooleanremoveRange(B b) Removes all pairs with a given right component from this multimap.booleanbooleanremoveUnchecked(Object a, Object b) booleanretainAllDomain(Collection<? extends A> c) Removes all pairs with a left component which is not the given collection from this multimap.booleanbooleanretainAllRange(Collection<? extends B> c) Removes all pairs with a right component which is not the given collection from this multimap.booleanMethods inherited from interface java.util.function.BiPredicate
and, negate, or, testMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Method Details
-
add
Adds a pair to this multimap. This operation must be stable: adding a pair thatequalsany pair contained in this multimap componentwise must not change this multimap.- Parameters:
a- the left component of the pair to add.b- the right component of the pair to add.- Returns:
trueif this multimap has been changed by this operation,falseotherwise.- Throws:
NullPointerException- (optionally) ifaorbisnull.IllegalArgumentException- (optionally) ifaorbisnull.
-
contains
Whether this multimap contains a pair with the given components.- Parameters:
a- the left component of the pair to add.b- the right component of the pair to add.
-
containsUnchecked
- See Also:
-
remove
Removes a pair from this this multimap. Removing a pair thatequalsno pair contained in this multimap componentwise must not change this multimap.- Parameters:
a- the left component of the pair to remove.b- the right component of the pair to remove.- Returns:
trueif this multimap has been changed by this operation,falseotherwise.- Throws:
NullPointerException- (optionally) ifaorbisnull.IllegalArgumentException- (optionally) ifaorbisnull.
-
removeUnchecked
- See Also:
-
removeDomain
Removes all pairs with a given left component from this multimap. The effect of the implementation on this multimap must be equivalent to the following code:removeDomain(final A a) { for (B b : new HashSet<B>(range())) remove(a, b) ; }- Parameters:
a- the left component of all pairs to remove.- Returns:
trueif this multimap has been changed by this operation,falseotherwise.- Throws:
NullPointerException- (optionally) ifaisnull.IllegalArgumentException- (optionally) ifaisnull.
-
removeDomainUnchecked
-
removeRange
Removes all pairs with a given right component from this multimap. The effect of the implementation on this multimap must be equivalent to the following code:removeRange(final B b) { for (A a : new HashSet<A>(domain())) remove(a, b) ; }- Parameters:
b- the right component of all pairs to remove.- Returns:
trueif this multimap has been changed by this operation,falseotherwise.- Throws:
NullPointerException- (optionally) ifbisnull.IllegalArgumentException- (optionally) ifbisnull.
-
removeRangeUnchecked
-
removeAllDomain
Removes all pairs with a left component in the given collection from this multimap. -
removeAllDomainUnchecked
- See Also:
-
retainAllDomain
Removes all pairs with a left component which is not the given collection from this multimap. -
retainAllDomainUnchecked
- See Also:
-
removeAllRange
Removes all pairs with a right component in the given collection from this multimap. -
removeAllRangeUnchecked
- See Also:
-
retainAllRange
Removes all pairs with a right component which is not the given collection from this multimap. -
retainAllRangeUnchecked
- See Also:
-
domain
Returns the set of left components of pairs in this multimap.The returned set is backed by this multimap, such that changes to this multimap are reflected by the set. The behavior of modifications of this multimap concurrent to iteration of the set is unspecified.
If this multimap supports the
removeDomainoperation, then the returned set and its iterators must support theremoveoperation, and changes by these operations must be reflected by this multimap.- Returns:
- the set of left components of pairs in this multimap.
-
range
Returns the set of right components of pairs in this multimap.If this multimap supports the
removeRangeoperation, then the returned set and its iterators must support theremoveoperation.- Returns:
- the set of right components of pairs in this multimap.
-
image
Returns the set of right components of pairs with a given left component in this multimap.The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.
- Parameters:
a- a left component.- Returns:
- the set of right components of pairs with a left
component that
equals(a)in this multimap. - Throws:
NullPointerException- ifaisnull.IllegalArgumentException- ifaisnull.
-
imageUnchecked
- See Also:
-
imageAll
Returns the set of right components of pairs in this multimap, which have a left component in the given set. -
imageAllUnchecked
- See Also:
-
imageMap
Returns a map which maps each A which appears as a left component to a set of all B which appear as its right component. -
preimage
Returns the set of left components of pairs with a given right component in this multimap.The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.
- Parameters:
b- a right component.- Returns:
- the set of left components of pairs with a right
component that
equals(b)in this multimap. - Throws:
NullPointerException- ifbisnull.IllegalArgumentException- ifbisnull.
-
preimageUnchecked
- See Also:
-
preimageAll
Returns the set of left components of pairs in this multimap, which have a right component in the given set. -
preimageAllUnchecked
- See Also:
-
preimageMap
Returns a map which maps each B which appears as a right component to a set of all A which appear as its left component.
-