Class AbstractMultiSetDecorator<E>
- java.lang.Object
-
- org.apache.commons.collections4.collection.AbstractCollectionDecorator<E>
-
- org.apache.commons.collections4.multiset.AbstractMultiSetDecorator<E>
-
- Type Parameters:
E
- the type held in the multiset
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,MultiSet<E>
- Direct Known Subclasses:
UnmodifiableMultiSet
public abstract class AbstractMultiSetDecorator<E> extends AbstractCollectionDecorator<E> implements MultiSet<E>
Decorates anotherMultSet
to provide additional behaviour.Methods are forwarded directly to the decorated multiset.
- Since:
- 4.1
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.collections4.MultiSet
MultiSet.Entry<E>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add(E object, int count)
Adds a number of occurrences of the specified object to the MultiSet.java.util.Set<MultiSet.Entry<E>>
entrySet()
Returns aSet
of all entries contained in the MultiSet.boolean
equals(java.lang.Object object)
Compares this MultiSet to another object.int
getCount(java.lang.Object object)
Returns the number of occurrences of the given object currently in the MultiSet.int
hashCode()
Gets a hash code for the MultiSet compatible with the definition of equals.int
remove(java.lang.Object object, int count)
Removes a number of occurrences of the specified object from the MultiSet.int
setCount(E object, int count)
Sets the number of occurrences of the specified object in the MultiSet to the given count.java.util.Set<E>
uniqueSet()
Returns aSet
of unique elements in the MultiSet.-
Methods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecorator
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, toArray, toArray, toString
-
-
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
Description copied from interface:MultiSet
Compares this MultiSet to another object.This MultiSet equals another object if it is also a MultiSet that contains the same number of occurrences of the same elements.
-
hashCode
public int hashCode()
Description copied from interface:MultiSet
Gets a hash code for the MultiSet compatible with the definition of equals. The hash code is defined as the sum total of a hash code for each element. The per element hash code is defined as(e==null ? 0 : e.hashCode()) ^ noOccurances)
.
-
getCount
public int getCount(java.lang.Object object)
Description copied from interface:MultiSet
Returns the number of occurrences of the given object currently in the MultiSet. If the object does not exist in the multiset, return 0.
-
setCount
public int setCount(E object, int count)
Description copied from interface:MultiSet
Sets the number of occurrences of the specified object in the MultiSet to the given count.If the provided count is zero, the object will be removed from the
MultiSet.uniqueSet()
.
-
add
public int add(E object, int count)
Description copied from interface:MultiSet
Adds a number of occurrences of the specified object to the MultiSet.If the object is already in the
MultiSet.uniqueSet()
then increment its count as reported byMultiSet.getCount(Object)
. Otherwise add it to theMultiSet.uniqueSet()
and report its count asoccurrences
.
-
remove
public int remove(java.lang.Object object, int count)
Description copied from interface:MultiSet
Removes a number of occurrences of the specified object from the MultiSet.If the number of occurrences to remove is greater than the actual number of occurrences in the multiset, the object will be removed from the multiset.
-
uniqueSet
public java.util.Set<E> uniqueSet()
Description copied from interface:MultiSet
Returns aSet
of unique elements in the MultiSet.Uniqueness constraints are the same as those in
Set
.The returned set is backed by this multiset, so any change to either is immediately reflected in the other. Only removal operations are supported, in which case all occurrences of the element are removed from the backing multiset.
-
entrySet
public java.util.Set<MultiSet.Entry<E>> entrySet()
Description copied from interface:MultiSet
Returns aSet
of all entries contained in the MultiSet.The returned set is backed by this multiset, so any change to either is immediately reflected in the other.
-
-