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

public abstract Class AbstractMapMultiSet<E>

extends AbstractMultiSet<E>
Class Inheritance
Known Direct Subclasses
org.apache.commons.collections4.multiset.HashMultiSet
Type Parameters
<E>
the type held in the multiset
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.lang.reflect.Array, java.util.ConcurrentModificationException, .Iterator, .Map, org.apache.commons.collections4.MultiSet, org.apache.commons.collections4.iterators.AbstractIteratorDecorator

Abstract implementation of the MultiSet interface to simplify the creation of subclass implementations.

Subclasses specify a Map implementation to use as the internal storage. The map will be used to map multiset elements to a number; the number represents the number of occurrences of that element in the multiset.

Since
4.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
AbstractMapMultiSet.EntrySetIterator<E>

Inner class EntrySetIterator.

private static class
AbstractMapMultiSet.MapBasedMultiSetIterator<E>

Inner class iterator for the MultiSet.

protected static class
AbstractMapMultiSet.MultiSetEntry<E>

Inner class MultiSetEntry.

protected static class
AbstractMapMultiSet.MutableInteger

Mutable integer class for storing the data.

protected static class
AbstractMapMultiSet.UniqueSetIterator<E>

Inner class UniqueSetIterator.

Field Summary

Modifier and TypeField and Description
private transient Map<E, AbstractMapMultiSet.MutableInteger>
map

The map to use to store the data

private transient int
modCount

The modification count for fail fast iterators

private transient int
size

The current total size of the multiset

Constructor Summary

AccessConstructor and Description
protected
AbstractMapMultiSet()

Constructor needed for subclass serialisation.

protected
AbstractMapMultiSet(final Map<E, AbstractMapMultiSet.MutableInteger>
the map to assign
map
)

Constructor that assigns the specified Map as the backing store.

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

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.add.

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

Adds a number of occurrences of the specified object to the MultiSet.
public void
clear()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.clear.

Implements java.util.Collection.clear.

Clears the multiset by clearing the underlying map.
public boolean

Returns:

true if the multiset contains the given element
contains
(final Object
the object to search for
object
)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.contains.

Implements java.util.Collection.contains.

Determines if the multiset contains the given element by checking if the underlying map contains the element as a key.
protected Iterator<MultiSet.Entry<E>>
protected Iterator<E>
protected void
doReadObject(final ObjectInputStream
the input stream
in
)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.doReadObject.

Read the multiset in using a custom routine.
protected void
doWriteObject(final ObjectOutputStream
the output stream
out
)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.doWriteObject.

Write the multiset out using a custom routine.
public boolean
equals(final Object
the object to compare to
object
)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.equals.

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

Compares this MultiSet to another object.
public int

Returns:

the number of occurrences of the object, zero if not found
getCount
(final Object
the object to search for
object
)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.getCount.

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

Returns the number of occurrence of the given element in this multiset by looking up its count in the underlying map.
protected Map<E, AbstractMapMultiSet.MutableInteger>

Returns:

the map being used by the MultiSet
getMap
()

Utility method for implementations to access the map that backs this multiset.

public int
hashCode()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.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 boolean

Returns:

true if multiset is empty
isEmpty
()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty.

Returns true if the underlying map is empty.
public Iterator<E>
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
occurrences
)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.remove.

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

Removes a number of occurrences of the specified object from the MultiSet.
protected void
setMap(final Map<E, AbstractMapMultiSet.MutableInteger>
the map to wrap
map
)

Sets the map being wrapped.

public int

Returns:

current size of the multiset
size
()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.size.

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

Returns the number of elements in this multiset.
public Object[]

Returns:

an array of all of this multiset's elements
toArray
()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Returns an array of all of this multiset's elements.
public <
the type of the array elements
T
>
T[]

Returns:

an array of all of this multiset's elements
toArray
(T[]
the array to populate
array
)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Returns an array of all of this multiset's elements.
protected int
uniqueElements()

Implements abstract org.apache.commons.collections4.multiset.AbstractMultiSet.uniqueElements.

Returns the number of unique elements in this multiset.
Inherited from org.apache.commons.collections4.multiset.AbstractMultiSet:
addcreateEntrySetcreateUniqueSetentrySetremoveremoveAllsetCounttoStringuniqueSet

Field Detail

mapback to summary
private transient Map<E, AbstractMapMultiSet.MutableInteger> map

The map to use to store the data

modCountback to summary
private transient int modCount

The modification count for fail fast iterators

sizeback to summary
private transient int size

The current total size of the multiset

Constructor Detail

AbstractMapMultiSetback to summary
protected AbstractMapMultiSet()

Constructor needed for subclass serialisation.

AbstractMapMultiSetback to summary
protected AbstractMapMultiSet(final Map<E, AbstractMapMultiSet.MutableInteger> map)

Constructor that assigns the specified Map as the backing store. The map must be empty and non-null.

Parameters
map:Map<E, AbstractMapMultiSet.MutableInteger>

the map to assign

Method Detail

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

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.add.

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

occurrences: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
clearback to summary
public void clear()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.clear.

Implements java.util.Collection.clear.

Clears the multiset by clearing the underlying map.

Annotations
@Override
containsback to summary
public boolean contains(final Object object)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.contains.

Implements java.util.Collection.contains.

Determines if the multiset contains the given element by checking if the underlying map contains the element as a key.

Parameters
object:Object

the object to search for

Returns:boolean

true if the multiset contains the given element

Annotations
@Override
createEntrySetIteratorback to summary
protected Iterator<MultiSet.Entry<E>> createEntrySetIterator()

Implements abstract org.apache.commons.collections4.multiset.AbstractMultiSet.createEntrySetIterator.

Doc from org.apache.commons.collections4.multiset.AbstractMultiSet.createEntrySetIterator.

Creates an entry set iterator. Subclasses can override this to return iterators with different properties.

Returns:Iterator<MultiSet.Entry<E>>

the entrySet iterator

Annotations
@Override
createUniqueSetIteratorback to summary
protected Iterator<E> createUniqueSetIterator()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.createUniqueSetIterator.

Doc from org.apache.commons.collections4.multiset.AbstractMultiSet.createUniqueSetIterator.

Creates a unique set iterator. Subclasses can override this to return iterators with different properties.

Returns:Iterator<E>

the uniqueSet iterator

Annotations
@Override
doReadObjectback to summary
protected void doReadObject(final ObjectInputStream in) throws IOException, ClassNotFoundException

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.doReadObject.

Read the multiset in using a custom routine.

Parameters
in:ObjectInputStream

the input stream

Annotations
@Override
Exceptions
IOException:
any of the usual I/O related exceptions
ClassNotFoundException:
if the stream contains an object which class can not be loaded
ClassCastException:
if the stream does not contain the correct objects
doWriteObjectback to summary
protected void doWriteObject(final ObjectOutputStream out) throws IOException

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.doWriteObject.

Write the multiset out using a custom routine.

Parameters
out:ObjectOutputStream

the output stream

Annotations
@Override
Exceptions
IOException:
any of the usual I/O related exceptions
equalsback to summary
public boolean equals(final Object object)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.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)

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.getCount.

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

Returns the number of occurrence of the given element in this multiset by looking up its count in the underlying map.

Parameters
object:Object

the object to search for

Returns:int

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

Annotations
@Override
getMapback to summary
protected Map<E, AbstractMapMultiSet.MutableInteger> getMap()

Utility method for implementations to access the map that backs this multiset. Not intended for interactive use outside of subclasses.

Returns:Map<E, AbstractMapMultiSet.MutableInteger>

the map being used by the MultiSet

hashCodeback to summary
public int hashCode()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.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
isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.Collection.isEmpty.

Returns true if the underlying map is empty.

Returns:boolean

true if multiset is empty

Annotations
@Override
iteratorback to summary
public Iterator<E> iterator()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.iterator.

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

Gets an iterator over the multiset elements. Elements present in the MultiSet more than once will be returned repeatedly.

Returns:Iterator<E>

the iterator

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

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.remove.

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

occurrences: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
setMapback to summary
protected void setMap(final Map<E, AbstractMapMultiSet.MutableInteger> map)

Sets the map being wrapped.

Note

this method should only be used during deserialization

Parameters
map:Map<E, AbstractMapMultiSet.MutableInteger>

the map to wrap

sizeback to summary
public int size()

Overrides org.apache.commons.collections4.multiset.AbstractMultiSet.size.

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

Returns the number of elements in this multiset.

Returns:int

current size of the multiset

Annotations
@Override
toArrayback to summary
public Object[] toArray()

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Returns an array of all of this multiset's elements.

Returns:Object[]

an array of all of this multiset's elements

Annotations
@Override
toArrayback to summary
public <T> T[] toArray(T[] array)

Overrides java.util.AbstractCollection.toArray.

Implements java.util.Collection.toArray.

Returns an array of all of this multiset's elements. If the input array has more elements than are in the multiset, trailing elements will be set to null.

Parameters
<T>
the type of the array elements
array:T[]

the array to populate

Returns:T[]

an array of all of this multiset's elements

Annotations
@Override
Exceptions
ArrayStoreException:
if the runtime type of the specified array is not a supertype of the runtime type of the elements in this list
NullPointerException:
if the specified array is null
uniqueElementsback to summary
protected int uniqueElements()

Implements abstract org.apache.commons.collections4.multiset.AbstractMultiSet.uniqueElements.

Doc from org.apache.commons.collections4.multiset.AbstractMultiSet.uniqueElements.

Returns the number of unique elements in this multiset.

Returns:int

the number of unique elements

Annotations
@Override
org.apache.commons.collections4.multiset back to summary

protected Class AbstractMapMultiSet.EntrySetIterator<E>

extends Object
implements Iterator<MultiSet.Entry<E>>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.collections4.multiset.AbstractMapMultiSet.EntrySetIterator
All Implemented Interfaces
java.util.Iterator

Inner class EntrySetIterator.

Field Summary

Modifier and TypeField and Description
protected boolean
canRemove

Whether remove is allowed at present

protected final Iterator<Map.Entry<E, AbstractMapMultiSet.MutableInteger>>
protected MultiSet.Entry<E>
last

The last returned entry

protected final AbstractMapMultiSet<E>
parent

The parent map

Constructor Summary

AccessConstructor and Description
protected
EntrySetIterator(final Iterator<Map.Entry<E, AbstractMapMultiSet.MutableInteger>>
the iterator to decorate
iterator
,
final AbstractMapMultiSet<E>
the parent multiset
parent
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public MultiSet.Entry<E>
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canRemoveback to summary
protected boolean canRemove

Whether remove is allowed at present

decoratedback to summary
protected final Iterator<Map.Entry<E, AbstractMapMultiSet.MutableInteger>> decorated
lastback to summary
protected MultiSet.Entry<E> last

The last returned entry

parentback to summary
protected final AbstractMapMultiSet<E> parent

The parent map

Constructor Detail

EntrySetIteratorback to summary
protected EntrySetIterator(final Iterator<Map.Entry<E, AbstractMapMultiSet.MutableInteger>> iterator, final AbstractMapMultiSet<E> parent)

Constructor.

Parameters
iterator:Iterator<Map.Entry<E, AbstractMapMultiSet.MutableInteger>>

the iterator to decorate

parent:AbstractMapMultiSet<E>

the parent multiset

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public MultiSet.Entry<E> next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:MultiSet.Entry<E>

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
org.apache.commons.collections4.multiset back to summary

private Class AbstractMapMultiSet.MapBasedMultiSetIterator<E>

extends Object
implements Iterator<E>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.collections4.multiset.AbstractMapMultiSet.MapBasedMultiSetIterator
All Implemented Interfaces
java.util.Iterator

Inner class iterator for the MultiSet.

Field Summary

Modifier and TypeField and Description
private boolean
private Map.Entry<E, AbstractMapMultiSet.MutableInteger>
private final Iterator<Map.Entry<E, AbstractMapMultiSet.MutableInteger>>
private int
private final int
private final AbstractMapMultiSet<E>

Constructor Summary

AccessConstructor and Description
public
MapBasedMultiSetIterator(final AbstractMapMultiSet<E>
the parent multiset
parent
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public E
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

canRemoveback to summary
private boolean canRemove
currentback to summary
private Map.Entry<E, AbstractMapMultiSet.MutableInteger> current
entryIteratorback to summary
private final Iterator<Map.Entry<E, AbstractMapMultiSet.MutableInteger>> entryIterator
itemCountback to summary
private int itemCount
modsback to summary
private final int mods
parentback to summary
private final AbstractMapMultiSet<E> parent

Constructor Detail

MapBasedMultiSetIteratorback to summary
public MapBasedMultiSetIterator(final AbstractMapMultiSet<E> parent)

Constructor.

Parameters
parent:AbstractMapMultiSet<E>

the parent multiset

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public E next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:E

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
org.apache.commons.collections4.multiset back to summary

protected Class AbstractMapMultiSet.MultiSetEntry<E>

extends AbstractMultiSet.AbstractEntry<E>
Class Inheritance

Inner class MultiSetEntry.

Field Summary

Modifier and TypeField and Description
protected final Map.Entry<E, AbstractMapMultiSet.MutableInteger>

Constructor Summary

AccessConstructor and Description
protected
MultiSetEntry(final Map.Entry<E, AbstractMapMultiSet.MutableInteger>
the entry to decorate
parentEntry
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int
getCount()

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

Returns the number of occurrences for the element of this entry.
public E
getElement()

Implements org.apache.commons.collections4.MultiSet.Entry.getElement.

Returns the element corresponding to this entry.
Inherited from org.apache.commons.collections4.multiset.AbstractMultiSet.AbstractEntry:
equalshashCodetoString

Field Detail

parentEntryback to summary
protected final Map.Entry<E, AbstractMapMultiSet.MutableInteger> parentEntry

Constructor Detail

MultiSetEntryback to summary
protected MultiSetEntry(final Map.Entry<E, AbstractMapMultiSet.MutableInteger> parentEntry)

Constructor.

Parameters
parentEntry:Map.Entry<E, AbstractMapMultiSet.MutableInteger>

the entry to decorate

Method Detail

getCountback to summary
public int getCount()

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

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

Returns the number of occurrences for the element of this entry.

Returns:int

the number of occurrences of the element

Annotations
@Override
getElementback to summary
public E getElement()

Implements org.apache.commons.collections4.MultiSet.Entry.getElement.

Doc from org.apache.commons.collections4.MultiSet.Entry.getElement.

Returns the element corresponding to this entry.

Returns:E

the element corresponding to this entry

Annotations
@Override
org.apache.commons.collections4.multiset back to summary

protected Class AbstractMapMultiSet.MutableInteger

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.collections4.multiset.AbstractMapMultiSet.MutableInteger

Mutable integer class for storing the data.

Field Summary

Modifier and TypeField and Description
protected int
value

The value of this mutable.

Constructor Summary

AccessConstructor and Description
pack-priv
MutableInteger(final int
the initial value
value
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

valueback to summary
protected int value

The value of this mutable.

Constructor Detail

MutableIntegerback to summary
pack-priv MutableInteger(final int value)

Constructor.

Parameters
value:int

the initial value

Method Detail

equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
org.apache.commons.collections4.multiset back to summary

protected Class AbstractMapMultiSet.UniqueSetIterator<E>

extends AbstractIteratorDecorator<E>
Class Inheritance

Inner class UniqueSetIterator.

Field Summary

Modifier and TypeField and Description
protected boolean
canRemove

Whether remove is allowed at present

protected E
lastElement

The last returned element

protected final AbstractMapMultiSet<E>
parent

The parent multiset

Constructor Summary

AccessConstructor and Description
protected
UniqueSetIterator(final Iterator<E>
the iterator to decorate
iterator
,
final AbstractMapMultiSet<E>
the parent multiset
parent
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public E
next()

Overrides org.apache.commons.collections4.iterators.AbstractIteratorDecorator.next.

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides org.apache.commons.collections4.iterators.AbstractUntypedIteratorDecorator.remove.

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

Field Detail

canRemoveback to summary
protected boolean canRemove

Whether remove is allowed at present

lastElementback to summary
protected E lastElement

The last returned element

parentback to summary
protected final AbstractMapMultiSet<E> parent

The parent multiset

Constructor Detail

UniqueSetIteratorback to summary
protected UniqueSetIterator(final Iterator<E> iterator, final AbstractMapMultiSet<E> parent)

Constructor.

Parameters
iterator:Iterator<E>

the iterator to decorate

parent:AbstractMapMultiSet<E>

the parent multiset

Method Detail

nextback to summary
public E next()

Overrides org.apache.commons.collections4.iterators.AbstractIteratorDecorator.next.

Implements java.util.Iterator.next.

Doc from org.apache.commons.collections4.iterators.AbstractIteratorDecorator.next.

Returns the next element in the iteration.

Returns:E

Doc from java.util.Iterator.next.

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides org.apache.commons.collections4.iterators.AbstractUntypedIteratorDecorator.remove.

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override