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

public abstract Class AbstractMultiSet<E>

extends AbstractCollection<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.multimap.AbstractMultiValuedMap.KeysMultiSet, org.apache.commons.collections4.multiset.AbstractMapMultiSet
Type Parameters
<E>
the type held in the multiset
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.util.AbstractCollection, .AbstractSet, .Collection, .Iterator, .Set, org.apache.commons.collections4.IteratorUtils, .MultiSet, .Transformer

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected abstract static class
AbstractMultiSet.AbstractEntry<E>

Inner class AbstractEntry.

protected static class
AbstractMultiSet.EntrySet<E>

Inner class EntrySet.

private static class
AbstractMultiSet.MultiSetIterator<E>

Inner class iterator for the MultiSet.

protected static class
AbstractMultiSet.UniqueSet<E>

Inner class UniqueSet.

Field Summary

Modifier and TypeField and Description
private transient Set<MultiSet.Entry<E>>
entrySet

View of the entries

private transient Set<E>
uniqueSet

View of the elements

Constructor Summary

AccessConstructor and Description
protected
AbstractMultiSet()

Constructor needed for subclass serialisation.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(final E
the object to add
object
)

Overrides java.util.AbstractCollection.add.

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

Adds one copy of the specified object to the MultiSet.
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
)

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

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

Overrides java.util.AbstractCollection.clear.

Implements java.util.Collection.clear.

Clears the multiset removing all elements from the entrySet.
public boolean

Returns:

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

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Determines if the multiset contains the given element.
protected Set<MultiSet.Entry<E>>

Returns:

a view of the set of entries
createEntrySet
()

Create a new view for the set of entries in this multiset.

protected abstract Iterator<MultiSet.Entry<E>>

Returns:

the entrySet iterator
createEntrySetIterator
()

Creates an entry set iterator.

protected Set<E>

Returns:

a view of the set of unique elements
createUniqueSet
()

Create a new view for the set of unique elements in this multiset.

protected Iterator<E>

Returns:

the uniqueSet iterator
createUniqueSetIterator
()

Creates a unique set iterator.

protected void
doReadObject(final ObjectInputStream
the input stream
in
)

Read the multiset in using a custom routine.

protected void
doWriteObject(final ObjectOutputStream
the output stream
out
)

Write the multiset out using a custom routine.

public Set<MultiSet.Entry<E>>

Returns:

the set of entries in this multiset
entrySet
()

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

Returns an unmodifiable view of the entries of this 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

Returns:

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

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

Returns the number of occurrence of the given element in this multiset by iterating over its entrySet.
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 Iterator<E>

Returns:

the iterator
iterator
()

Implements abstract java.util.AbstractCollection.iterator.

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

Gets an iterator over the multiset elements.
public boolean
remove(final Object
the object to remove
object
)

Overrides java.util.AbstractCollection.remove.

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

Removes one occurrence of the given object from the MultiSet.
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
)

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

Removes a number of occurrences of the specified object from the MultiSet.
public boolean
removeAll(final Collection<?>
the collection of elements to remove
coll
)

Overrides java.util.AbstractCollection.removeAll.

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

Remove all occurrences of all elements from this MultiSet represented in the given collection.
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 int

Returns:

current size of the multiset
size
()

Implements abstract java.util.AbstractCollection.size.

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

Returns the number of elements in this multiset.
public String

Returns:

a debugging toString
toString
()

Overrides java.util.AbstractCollection.toString.

Implement a toString() method suitable for debugging.
protected abstract int

Returns:

the number of unique elements
uniqueElements
()

Returns the number of unique elements in this multiset.

public Set<E>

Returns:

the set of unique elements in this multiset
uniqueSet
()

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

Returns a view of the unique elements of this multiset.
Inherited from java.util.AbstractCollection:
addAllcontainsAllisEmptyretainAlltoArraytoArray

Field Detail

entrySetback to summary
private transient Set<MultiSet.Entry<E>> entrySet

View of the entries

uniqueSetback to summary
private transient Set<E> uniqueSet

View of the elements

Constructor Detail

AbstractMultiSetback to summary
protected AbstractMultiSet()

Constructor needed for subclass serialisation.

Method Detail

addback to summary
public boolean add(final E object)

Overrides java.util.AbstractCollection.add.

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

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

Adds one copy 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 1.

Parameters
object:E

the object to add

Returns:boolean

true always, as the size of the MultiSet is increased in any case

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

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 java.util.AbstractCollection.clear.

Implements java.util.Collection.clear.

Clears the multiset removing all elements from the entrySet.

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

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Determines if the multiset contains the given element.

Parameters
object:Object

the object to search for

Returns:boolean

true if the multiset contains the given element

Annotations
@Override
createEntrySetback to summary
protected Set<MultiSet.Entry<E>> createEntrySet()

Create a new view for the set of entries in this multiset.

Returns:Set<MultiSet.Entry<E>>

a view of the set of entries

createEntrySetIteratorback to summary
protected abstract Iterator<MultiSet.Entry<E>> createEntrySetIterator()

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

Returns:Iterator<MultiSet.Entry<E>>

the entrySet iterator

createUniqueSetback to summary
protected Set<E> createUniqueSet()

Create a new view for the set of unique elements in this multiset.

Returns:Set<E>

a view of the set of unique elements

createUniqueSetIteratorback to summary
protected Iterator<E> createUniqueSetIterator()

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

Returns:Iterator<E>

the uniqueSet iterator

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

Read the multiset in using a custom routine.

Parameters
in:ObjectInputStream

the input stream

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

Write the multiset out using a custom routine.

Parameters
out:ObjectOutputStream

the output stream

Exceptions
IOException:
any of the usual I/O related exceptions
entrySetback to summary
public Set<MultiSet.Entry<E>> entrySet()

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

Returns an unmodifiable view of the entries of this multiset.

Returns:Set<MultiSet.Entry<E>>

the set of entries in this multiset

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.

Returns the number of occurrence of the given element in this multiset by iterating over its entrySet.

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
iteratorback to summary
public Iterator<E> iterator()

Implements abstract java.util.AbstractCollection.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 boolean remove(final Object object)

Overrides java.util.AbstractCollection.remove.

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

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

Removes one occurrence of the given object from the MultiSet.

If the number of occurrences after this operations is reduced to zero, the object will be removed from the uniqueSet().

Parameters
object:Object

the object to remove

Returns:boolean

true if this call changed the collection

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

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
removeAllback to summary
public boolean removeAll(final Collection<?> coll)

Overrides java.util.AbstractCollection.removeAll.

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

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

Remove all occurrences of all elements from this MultiSet represented in the given collection.

Parameters
coll:Collection<?>

the collection of elements to remove

Returns:boolean

true if this call changed the multiset

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
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.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
toStringback to summary
public String toString()

Overrides java.util.AbstractCollection.toString.

Implement a toString() method suitable for debugging.

Returns:String

a debugging toString

Annotations
@Override
uniqueElementsback to summary
protected abstract int uniqueElements()

Returns the number of unique elements in this multiset.

Returns:int

the number of unique elements

uniqueSetback to summary
public Set<E> uniqueSet()

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

Returns a view of the unique elements of this multiset.

Returns:Set<E>

the set of unique elements in this multiset

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

protected abstract Class AbstractMultiSet.AbstractEntry<E>

extends Object
implements MultiSet.Entry<E>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.collections4.multiset.AbstractMultiSet.AbstractEntry
All Implemented Interfaces
org.apache.commons.collections4.MultiSet.Entry
Known Direct Subclasses
org.apache.commons.collections4.multiset.AbstractMapMultiSet.MultiSetEntry

Inner class AbstractEntry.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
object to be compared for equality with this multiset entry
object
)

Overrides java.lang.Object.equals.

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

Compares the specified object with this entry for equality.
public int
hashCode()

Overrides java.lang.Object.hashCode.

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

Returns the hash code value for this multiset entry.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Constructor Detail

AbstractEntryback to summary
protected AbstractEntry()

Method Detail

equalsback to summary
public boolean equals(final Object object)

Overrides java.lang.Object.equals.

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

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

Compares the specified object with this entry for equality. Returns true if the given object is also a multiset entry and the two entries represent the same element with the same number of occurrences.

More formally, two entries e1 and e2 represent the same mapping if

    (e1.getElement()==null ? e2.getElement()==null
                           : e1.getElement().equals(e2.getElement())) &&
    (e1.getCount()==e2.getCount())
Parameters
object:Object

object to be compared for equality with this multiset entry

Returns:boolean

true if the specified object is equal to this multiset entry

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

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

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

Returns the hash code value for this multiset entry.

The hash code of a multiset entry e is defined to be:

     (e==null ? 0 : e.hashCode()) ^ noOccurances)
Returns:int

the hash code value for this multiset entry

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

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

protected Class AbstractMultiSet.EntrySet<E>

extends AbstractSet<MultiSet.Entry<E>>
Class Inheritance

Inner class EntrySet.

Field Summary

Modifier and TypeField and Description
private final AbstractMultiSet<E>

Constructor Summary

AccessConstructor and Description
protected
EntrySet(final AbstractMultiSet<E>
the parent MultiSet
parent
)

Constructs a new view of the MultiSet.

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(final Object
element whose presence in this set is to be tested
obj
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Returns true if this set contains the specified element.
public Iterator<MultiSet.Entry<E>>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this set.
public boolean
remove(final Object
object to be removed from this set, if present
obj
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes the specified element from this set if it is present (optional operation).
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set (its cardinality).
Inherited from java.util.AbstractSet:
equalshashCoderemoveAll

Field Detail

parentback to summary
private final AbstractMultiSet<E> parent

Constructor Detail

EntrySetback to summary
protected EntrySet(final AbstractMultiSet<E> parent)

Constructs a new view of the MultiSet.

Parameters
parent:AbstractMultiSet<E>

the parent MultiSet

Method Detail

containsback to summary
public boolean contains(final Object obj)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
obj:Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

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

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:Iterator<MultiSet.Entry<E>>

an iterator over the elements in this set

Annotations
@Override
removeback to summary
public boolean remove(final Object obj)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Doc from java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)

Parameters
obj:Object

object to be removed from this set, if present

Returns:boolean

true if this set contained the specified element

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this set (its cardinality)

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

private Class AbstractMultiSet.MultiSetIterator<E>

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

Inner class iterator for the MultiSet.

Field Summary

Modifier and TypeField and Description
private boolean
private MultiSet.Entry<E>
private final Iterator<MultiSet.Entry<E>>
private int
private final AbstractMultiSet<E>

Constructor Summary

AccessConstructor and Description
public
MultiSetIterator(final AbstractMultiSet<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 MultiSet.Entry<E> current
entryIteratorback to summary
private final Iterator<MultiSet.Entry<E>> entryIterator
itemCountback to summary
private int itemCount
parentback to summary
private final AbstractMultiSet<E> parent

Constructor Detail

MultiSetIteratorback to summary
public MultiSetIterator(final AbstractMultiSet<E> parent)

Constructor.

Parameters
parent:AbstractMultiSet<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 AbstractMultiSet.UniqueSet<E>

extends AbstractSet<E>
Class Inheritance

Inner class UniqueSet.

Field Summary

Modifier and TypeField and Description
protected final AbstractMultiSet<E>
parent

The parent multiset

Constructor Summary

AccessConstructor and Description
protected
UniqueSet(final AbstractMultiSet<E>
the parent MultiSet
parent
)

Constructs a new unique element view of the MultiSet.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Removes all of the elements from this set (optional operation).
public boolean
contains(final Object
element whose presence in this set is to be tested
key
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Returns true if this set contains the specified element.
public boolean
containsAll(final Collection<?>
collection to be checked for containment in this set
coll
)

Overrides java.util.AbstractCollection.containsAll.

Implements java.util.Set.containsAll, java.util.Collection.containsAll.

Returns true if this set contains all of the elements of the specified collection.
public Iterator<E>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Returns an iterator over the elements in this set.
public boolean
remove(final Object
object to be removed from this set, if present
key
)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Removes the specified element from this set if it is present (optional operation).
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Returns the number of elements in this set (its cardinality).
Inherited from java.util.AbstractSet:
equalshashCoderemoveAll

Field Detail

parentback to summary
protected final AbstractMultiSet<E> parent

The parent multiset

Constructor Detail

UniqueSetback to summary
protected UniqueSet(final AbstractMultiSet<E> parent)

Constructs a new unique element view of the MultiSet.

Parameters
parent:AbstractMultiSet<E>

the parent MultiSet

Method Detail

clearback to summary
public void clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Set.clear, java.util.Collection.clear.

Doc from java.util.Set.clear.

Removes all of the elements from this set (optional operation). The set will be empty after this call returns.

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

Overrides java.util.AbstractCollection.contains.

Implements java.util.Set.contains, java.util.Collection.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
key:Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

Annotations
@Override
containsAllback to summary
public boolean containsAll(final Collection<?> coll)

Overrides java.util.AbstractCollection.containsAll.

Implements java.util.Set.containsAll, java.util.Collection.containsAll.

Doc from java.util.Set.containsAll.

Returns true if this set contains all of the elements of the specified collection. If the specified collection is also a set, this method returns true if it is a subset of this set.

Parameters
coll:Collection<?>

collection to be checked for containment in this set

Returns:boolean

true if this set contains all of the elements of the specified collection

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

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Set.iterator, java.util.Collection.iterator.

Doc from java.util.Set.iterator.

Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).

Returns:Iterator<E>

an iterator over the elements in this set

Annotations
@Override
removeback to summary
public boolean remove(final Object key)

Overrides java.util.AbstractCollection.remove.

Implements java.util.Set.remove, java.util.Collection.remove.

Doc from java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)

Parameters
key:Object

object to be removed from this set, if present

Returns:boolean

true if this set contained the specified element

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Set.size, java.util.Collection.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this set (its cardinality)

Annotations
@Override