Class AbstractMultimap<A,B>
- Type Parameters:
A- type of the domain elementsB- type of the range elements
- All Implemented Interfaces:
Multimap<A,,B> Iterable<Map.Entry<A,,B>> Collection<Map.Entry<A,,B>> BiPredicate<A,,B> Set<Map.Entry<A,B>>
To implement an unmodifiable multimap, subclasses need only to implement
the methods AbstractCollection.iterator() and AbstractCollection.size().
To implement a modifiable collection, subclasses must also override the
method AbstractCollection.add(Object), and the iterators return by AbstractCollection.iterator()
must override the method Iterator.remove().
Subclasses that do not use Map.Entry objects for internal storage
are encouraged to override the methods add(Object,Object), remove(Object,Object), contains(Object,Object), Multimap.removeUnchecked(Object,Object) and Multimap.containsUnchecked(Object,Object).
Every subclass should define a copying constructor.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final AbstractMultimap<A, B> For to make "this" accessible by deeply nested anonymous classes.Fields inherited from interface eu.bandm.tools.util.multi.Multimap
DEFAULT_PAIR_FORMAT_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a pair to this multimap if not already present.booleanWhether this multimap contains a pair with the given components.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.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.Convenience method for untyped inquiry.Returns the set of left components of pairs with a given right component in this multimap.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.Convenience method for untyped inquiry.range()Returns the set of right components of pairs in this multimap.booleanRemoves a pair from this multimap.toString()Returns a string representation of this instance.Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArrayMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.function.BiPredicate
and, negate, orMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface eu.bandm.tools.util.multi.Multimap
addAll, containsAll, containsUnchecked, imageAll, imageAllUnchecked, preimageAll, preimageAllUnchecked, removeAll, removeAllDomain, removeAllDomainUnchecked, removeAllRange, removeAllRangeUnchecked, removeDomain, removeDomainUnchecked, removeRange, removeRangeUnchecked, removeUnchecked, retainAll, retainAllDomain, retainAllDomainUnchecked, retainAllRange, retainAllRangeUnchecked, test, toArray, toArray, toString, toString
-
Field Details
-
abstractMultimap
For to make "this" accessible by deeply nested anonymous classes.
-
-
Constructor Details
-
AbstractMultimap
protected AbstractMultimap()Creates a new instance.
-
-
Method Details
-
add
Adds a pair to this multimap if not already present.The default implementation calls
AbstractCollection.add(E)with a newly created map entry to hold the pair. Subclasses may override this method for a more efficient implementation. -
remove
Description copied from interface:MultimapRemoves a pair from this multimap. Removing a pair thatequalsno pair contained in this multimap componentwise must not change this multimap. -
contains
Description copied from interface:MultimapWhether this multimap contains a pair with the given components. -
domain
Description copied from interface:MultimapReturns 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. -
range
Description copied from interface:MultimapReturns the set of right 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
removeRangeoperation, then the returned set and its iterators must support theremoveoperation, and changes by these operations must be reflected by this multimap. -
image
Description copied from interface:MultimapReturns 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.
-
imageUnchecked
Description copied from interface:MultimapConvenience method for untyped inquiry.- Specified by:
imageUncheckedin interfaceMultimap<A,B> - Parameters:
a- a left component.- Returns:
- the set of right components of pairs with a left
component that
equals(a)in this multimap. - See Also:
-
imageMap
Description copied from interface:MultimapReturns a map which maps each A which appears as a left component to a set of all B which appear as its right component. The result is backed by the argument. Subsequent changes to either Collection are reflected by the other. -
preimage
Description copied from interface:MultimapReturns 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.
-
preimageUnchecked
Description copied from interface:MultimapConvenience method for untyped inquiry.- Specified by:
preimageUncheckedin interfaceMultimap<A,B> - Parameters:
b- a right component.- Returns:
- the set of left components of pairs with a right
component that
equals(b)in this multimap. - See Also:
-
preimageMap
Description copied from interface:MultimapReturns a map which maps each B which appears as a right component to a set of all A which appear as its left component. The result is backed by the argument. Subsequent changes to either Collection are reflected by the other.- Specified by:
preimageMapin interfaceMultimap<A,B> - 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.
-
toString
Returns a string representation of this instance. CallsMultimap.toString(String)withMultimap.DEFAULT_PAIR_FORMAT_STRING.- Overrides:
toStringin classAbstractCollection<Map.Entry<A,B>>
-