Package eu.bandm.tools.util.multi
Class AbstractMultiset<A>
java.lang.Object
eu.bandm.tools.util.multi.AbstractMultiset<A>
- Type Parameters:
A- type of the contained elements
- All Implemented Interfaces:
Multiset<A>,Serializable,Iterable<A>
- Direct Known Subclasses:
HashMultiset,TreeMultiset
Common superclass for sorted and unsorted domains.
- See Also:
-
Field Summary
Fields inherited from interface eu.bandm.tools.util.multi.Multiset
DEFAULT_MULTI_FORMAT_STRING, DEFAULT_SINGLE_FORMAT_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdd one element once to this set.booleanAdd one element multiple times to this set.voidclear()Remove all objects from this instance.booleanReturns whether a particular element is contained at least once in this set.booleanReturns whether a particular element is contained at least once in this set.intReturns how many times the given element is contained in this set.intcountAll(Collection<? extends A> c) Sum up how many times the elements in the given collection are contained in this set.intcountAllUnchecked(Collection<?> c) Sum up how many times the elements in the given collection are contained in this set.intReturns how many times the given element is contained in this set.domain()Returns the set of all elements contained at least once in this set.booleanisEmpty()Returns whether this set is empty.iterator()map()Returns the supporting map.booleanRemove the given element once from this set.booleanremoveAll(Collection<? extends A> c) Remove all elements in the given collection completely from this set.booleanremoveAllUnchecked(Collection<?> c) Remove all elements in the given collection completely from this set.booleanremoveDomain(A a) Remove the given element completely from this set.booleanRemove the given element completely from this set.booleanRemove the given element once from this set.booleanretainAll(Collection<? extends A> c) Remove all elements not contained in the given collection completely from this set.booleanretainAllUnchecked(Collection<?> c) Remove all elements not contained in the given collection completely from this set.Returns a map which assigns each element contained at least once in this set to how often it is contained.toString()Returns a string representation of this instance.protected intReturns how often the given object is contained in this set, including zero times.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AbstractMultiset
protected AbstractMultiset()Only constructor
-
-
Method Details
-
map
Returns the supporting map. That map Realizes containment by mapping every contained object to a number greater than zero, how often it is contained in this instance.- Returns:
- the supporting map.
-
isEmpty
public boolean isEmpty()Returns whether this set is empty. -
clear
public void clear()Remove all objects from this instance. -
xget
Returns how often the given object is contained in this set, including zero times.- Parameters:
a- the object to test- Returns:
- how often the given object is contained in this set, including zero times.
-
add
Add one element once to this set. This means to increase the number of contained elements by one. -
add
Add one element multiple times to this set. This means to increase the number of contained elements by the given mulitplicity. -
contains
Returns whether a particular element is contained at least once in this set. -
containsUnchecked
Returns whether a particular element is contained at least once in this set.- Specified by:
containsUncheckedin interfaceMultiset<A>- Parameters:
a- element to test.- Returns:
- whether a the given element is contained at least once in this set.
-
remove
Remove the given element once from this set. That means, decrement the number of its containments if and only if it is greater than zero. -
removeUnchecked
Remove the given element once from this set. That means, decrement the number of its containments iff it is greater zero.- Specified by:
removeUncheckedin interfaceMultiset<A>- Parameters:
a- element to remove.- Returns:
- whether this instance has changed.
-
removeDomain
Remove the given element completely from this set.- Specified by:
removeDomainin interfaceMultiset<A>- Parameters:
a- element to remove.- Returns:
- whether this instance has changed.
-
removeDomainUnchecked
Remove the given element completely from this set.- Specified by:
removeDomainUncheckedin interfaceMultiset<A>- Parameters:
a- element to remove.- Returns:
- whether this instance has changed.
-
removeAll
Remove all elements in the given collection completely from this set. -
removeAllUnchecked
Remove all elements in the given collection completely from this set.- Specified by:
removeAllUncheckedin interfaceMultiset<A>- Parameters:
c- collection of all elements to remove- Returns:
- whether this instance has changed
-
retainAll
Remove all elements not contained in the given collection completely from this set. -
retainAllUnchecked
Remove all elements not contained in the given collection completely from this set.- Specified by:
retainAllUncheckedin interfaceMultiset<A>- Parameters:
c- collection of all elements not to remove- Returns:
- whether this instance has changed
-
count
Returns how many times the given element is contained in this set. -
countUnchecked
Returns how many times the given element is contained in this set.- Specified by:
countUncheckedin interfaceMultiset<A>- Parameters:
o- the element to test.- Returns:
- how many times the given element is contained in this set.
-
countAll
Sum up how many times the elements in the given collection are contained in this set. -
countAllUnchecked
Sum up how many times the elements in the given collection are contained in this set.- Specified by:
countAllUncheckedin interfaceMultiset<A>- Parameters:
c- the collection of elements to count.- Returns:
- how many times the elements in the given collection are contained in this set.
-
iterator
-
domain
Returns the set of all elements contained at least once in this set. It holds thatdomain().equals(supportMap().keySet()). The result is backed by the argument. Changes to one collection are reflected by the other. -
supportMap
Returns a map which assigns each element contained at least once in this set to how often it is contained. It holds that no zero is contained in the range of this map. The result is backed by the argument. Changes to one collection are reflected by the other.- Specified by:
supportMapin interfaceMultiset<A>- Returns:
- a map which assigns each element contained at least once in this instance to how often it is contained.
-
toString
Returns a string representation of this instance. CallsMultiset.toString(java.lang.String, java.lang.String)with the argumentssMultiset.DEFAULT_MULTI_FORMAT_STRINGandMultiset.DEFAULT_SINGLE_FORMAT_STRING.
-