Top Description Fields Constructors Methods
org.apache.commons.collections4.multiset

public abstract Class AbstractMultiSetDecorator<E>

extends AbstractCollectionDecorator<E>
implements MultiSet<E>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.MultiSet, java.util.Collection, java.lang.Iterable
Known Direct Subclasses
org.apache.commons.collections4.multiset.UnmodifiableMultiSet
Type Parameters
<E>
the type held in the multiset
Imports
java.util.Set, org.apache.commons.collections4.MultiSet, org.apache.commons.collections4.collection.AbstractCollectionDecorator

Decorates another MultSet to provide additional behaviour.

Methods are forwarded directly to the decorated multiset.

Since
4.1

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
AbstractMultiSetDecorator()

Constructor only used in deserialization, do not use otherwise.

protected
AbstractMultiSetDecorator(final MultiSet<E>
the multiset to decorate, must not be null
multiset
)

Constructor that wraps (not copies).

Method Summary

Modifier and TypeMethod and Description
public int
add(final E
the object to add
object
,
final int
the number of occurrences to add, may be zero, in which case no change is made to the multiset
count
)

Implements org.apache.commons.collections4.MultiSet.add.

Adds a number of occurrences of the specified object to the MultiSet.
protected MultiSet<E>

Returns:

the decorated multiset
decorated
()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.decorated.

Gets the multiset being decorated.
public Set<MultiSet.Entry<E>>
entrySet()

Implements org.apache.commons.collections4.MultiSet.entrySet.

Returns a Set of all entries contained in the MultiSet.
public boolean
equals(final Object
the object to compare to
object
)

Overrides java.lang.Object.equals.

Implements org.apache.commons.collections4.MultiSet.equals, java.util.Collection.equals.

Compares this MultiSet to another object.
public int
getCount(final Object
the object to search for
object
)

Implements org.apache.commons.collections4.MultiSet.getCount.

Returns the number of occurrences of the given object currently in the MultiSet.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements org.apache.commons.collections4.MultiSet.hashCode, java.util.Collection.hashCode.

Gets a hash code for the MultiSet compatible with the definition of equals.
public int
remove(final Object
the object to remove
object
,
final int
the number of occurrences to remove, may be zero, in which case no change is made to the multiset
count
)

Implements org.apache.commons.collections4.MultiSet.remove.

Removes a number of occurrences of the specified object from the MultiSet.
public int
setCount(final E
the object to update
object
,
final int
the number of occurrences of the object
count
)

Implements org.apache.commons.collections4.MultiSet.setCount.

Sets the number of occurrences of the specified object in the MultiSet to the given count.
public Set<E>
uniqueSet()

Implements org.apache.commons.collections4.MultiSet.uniqueSet.

Returns a Set of unique elements in the MultiSet.
Inherited from org.apache.commons.collections4.collection.AbstractCollectionDecorator:
addaddAllclearcontainscontainsAllisEmptyiteratorremoveremoveAllremoveIfretainAllsetCollectionsizetoArraytoArraytoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.collections4.collection.AbstractCollectionDecorator.serialVersionUID.

Serialization version

Constructor Detail

AbstractMultiSetDecoratorback to summary
protected AbstractMultiSetDecorator()

Constructor only used in deserialization, do not use otherwise.

AbstractMultiSetDecoratorback to summary
protected AbstractMultiSetDecorator(final MultiSet<E> multiset)

Constructor that wraps (not copies).

Parameters
multiset:MultiSet<E>

the multiset to decorate, must not be null

Exceptions
NullPointerException:
if multiset is null

Method Detail

addback to summary
public int add(final E object, final int count)

Implements org.apache.commons.collections4.MultiSet.add.

Doc from org.apache.commons.collections4.MultiSet.add.

Adds a number of occurrences of the specified object to the MultiSet.

If the object is already in the uniqueSet() then increment its count as reported by getCount(Object). Otherwise add it to the uniqueSet() and report its count as occurrences.

Parameters
object:E

the object to add

count:int

the number of occurrences to add, may be zero, in which case no change is made to the multiset

Returns:int

the number of occurrences of the object in the multiset before this operation; possibly zero

Annotations
@Override
decoratedback to summary
protected MultiSet<E> decorated()

Overrides org.apache.commons.collections4.collection.AbstractCollectionDecorator.decorated.

Gets the multiset being decorated.

Returns:MultiSet<E>

the decorated multiset

Annotations
@Override
entrySetback to summary
public Set<MultiSet.Entry<E>> entrySet()

Implements org.apache.commons.collections4.MultiSet.entrySet.

Doc from org.apache.commons.collections4.MultiSet.entrySet.

Returns a Set 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.

Returns:Set<MultiSet.Entry<E>>

the Set of MultiSet entries

Annotations
@Override
equalsback to summary
public boolean equals(final Object object)

Overrides java.lang.Object.equals.

Implements org.apache.commons.collections4.MultiSet.equals, java.util.Collection.equals.

Doc from org.apache.commons.collections4.MultiSet.equals.

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.

Parameters
object:Object

the object to compare to

Returns:boolean

true if equal

Annotations
@Override
getCountback to summary
public int getCount(final Object object)

Implements org.apache.commons.collections4.MultiSet.getCount.

Doc from org.apache.commons.collections4.MultiSet.getCount.

Returns the number of occurrences of the given object currently in the MultiSet. If the object does not exist in the multiset, return 0.

Parameters
object:Object

the object to search for

Returns:int

the number of occurrences of the object, zero if not found

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.apache.commons.collections4.MultiSet.hashCode, java.util.Collection.hashCode.

Doc from org.apache.commons.collections4.MultiSet.hashCode.

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).

Returns:int

the hash code of the MultiSet

Annotations
@Override
removeback to summary
public int remove(final Object object, final int count)

Implements org.apache.commons.collections4.MultiSet.remove.

Doc from org.apache.commons.collections4.MultiSet.remove.

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.

Parameters
object:Object

the object to remove

count:int

the number of occurrences to remove, may be zero, in which case no change is made to the multiset

Returns:int

the number of occurrences of the object in the multiset before the operation; possibly zero

Annotations
@Override
setCountback to summary
public int setCount(final E object, final int count)

Implements org.apache.commons.collections4.MultiSet.setCount.

Doc from org.apache.commons.collections4.MultiSet.setCount.

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 uniqueSet().

Parameters
object:E

the object to update

count:int

the number of occurrences of the object

Returns:int

the number of occurrences of the object before this operation, zero if the object was not contained in the multiset

Annotations
@Override
uniqueSetback to summary
public Set<E> uniqueSet()

Implements org.apache.commons.collections4.MultiSet.uniqueSet.

Doc from org.apache.commons.collections4.MultiSet.uniqueSet.

Returns a Set of unique elements in the MultiSet.

Uniqueness constraints are the same as those in java.util.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.

Returns:Set<E>

the Set of unique MultiSet elements

Annotations
@Override