public interface Multimap<A,B> extends Relation<A,B>, Set<Map.Entry<A,B>>, Serializable
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.
Modifier and Type | Method and Description |
---|---|
boolean |
add(A a,
B b)
Adds a pair to this this multimap.
|
boolean |
contains(A a,
B b) |
boolean |
containsUnchecked(Object a,
Object b) |
Set<A> |
domain()
Returns the set of left components of pairs in this multimap.
|
Set<B> |
image(A a)
Returns the set of right components of pairs with a given left
component in this multimap.
|
Set<B> |
imageAll(Collection<? extends A> a) |
Set<B> |
imageAllUnchecked(Collection<?> a) |
Map<A,Set<B>> |
imageMap() |
Set<B> |
imageUnchecked(Object a) |
Set<A> |
preimage(B b)
Returns the set of left components of pairs with a given right
component in this multimap.
|
Set<A> |
preimageAll(Collection<? extends B> b) |
Set<A> |
preimageAllUnchecked(Collection<?> b) |
Map<B,Set<A>> |
preimageMap() |
Set<A> |
preimageUnchecked(Object b) |
Set<B> |
range()
Returns the set of right components of pairs in this multimap.
|
boolean |
remove(A a,
B b)
Removes a pair from this this multimap.
|
boolean |
removeAllDomain(Collection<? extends A> c) |
boolean |
removeAllDomainUnchecked(Collection<?> c) |
boolean |
removeAllRange(Collection<? extends B> c) |
boolean |
removeAllRangeUnchecked(Collection<?> c) |
boolean |
removeDomain(A a)
Removes all pairs with a given left component from this
multimap.
|
boolean |
removeRange(B b)
Removes all pairs with a given right component from this
multimap.
|
boolean |
removeUnchecked(Object a,
Object b) |
boolean |
retainAllDomain(Collection<? extends A> c) |
boolean |
retainAllDomainUnchecked(Collection<?> c) |
boolean |
retainAllRange(Collection<? extends B> c) |
boolean |
retainAllRangeUnchecked(Collection<?> c) |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray
parallelStream, removeIf, stream
boolean add(A a, B b)
equals
any pair contained in
this multimap componentwise must not change this multimap.a
- the left component of the pair to add.b
- the right component of the pair to add.true
if this multimap has been changed by this
operation, false
otherwise.NullPointerException
- (optionally) if a
or b
is null
.IllegalArgumentException
- (optionally) if a
or
b
is null
.boolean remove(A a, B b)
equals
no pair contained in this multimap componentwise
must not change this multimap.a
- the left component of the pair to remove.b
- the right component of the pair to remove.true
if this multimap has been changed by this
operation, false
otherwise.NullPointerException
- (optionally) if a
or b
is null
.IllegalArgumentException
- (optionally) if a
or
b
is null
.boolean removeDomain(A a)
removeDomain(final A a) { for (B b : new HashSet<B>(range())) remove(a, b) ; }
a
- the left component of all pairs to remove.true
if this multimap has been changed by this
operation, false
otherwise.NullPointerException
- (optionally) if a
is null
.IllegalArgumentException
- (optionally) if a
is
null
.boolean removeRange(B b)
removeRange(final B b) { for (A a : new HashSet<A>(domain())) remove(a, b) ; }
b
- the right component of all pairs to remove.true
if this multimap has been changed by this
operation, false
otherwise.NullPointerException
- (optionally) if b
is null
.IllegalArgumentException
- (optionally) if b
is
null
.boolean removeAllDomain(Collection<? extends A> c)
boolean removeAllDomainUnchecked(Collection<?> c)
boolean retainAllDomain(Collection<? extends A> c)
boolean retainAllDomainUnchecked(Collection<?> c)
boolean removeAllRange(Collection<? extends B> c)
boolean removeAllRangeUnchecked(Collection<?> c)
boolean retainAllRange(Collection<? extends B> c)
boolean retainAllRangeUnchecked(Collection<?> c)
Set<A> domain()
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 removeDomain
operation,
then the returned set and its iterators must support the remove
operation, and changes by these operations must be
reflected by this multimap.
Set<B> range()
If this multimap supports the removeRange
operation,
then the returned set and its iterators must support the remove
operation.
Set<B> image(A a)
The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.
a
- a left component.equals(a)
in this multimap.NullPointerException
- if a
is null
.IllegalArgumentException
- if a
is null
.Set<B> imageAll(Collection<? extends A> a)
Set<B> imageAllUnchecked(Collection<?> a)
Set<A> preimage(B b)
The returned set need not be modifiable. The behaviour of this multimap after successfully modifying the returned set is unspecified.
b
- a right component.equals(b)
in this multimap.NullPointerException
- if b
is null
.IllegalArgumentException
- if b
is null
.Set<A> preimageAll(Collection<? extends B> b)
Set<A> preimageAllUnchecked(Collection<?> b)
see also the complete user documentation .