MultiSet interface to simplify the
creation of subclass implementations.
| Modifier and Type | Class and Description |
|---|---|
| protected abstract static class | |
| protected static class | |
| private static class | |
| protected static class |
| Modifier and Type | Field and Description |
|---|---|
| private transient Set | entrySet
View of the entries |
| private transient Set | uniqueSet
View of the elements |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(final E
the object to add object)Overrides java. Implements org. |
| 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. |
| public void | clear()
Overrides java. Implements java. |
| public boolean | Returns: true if the multiset contains the given elementthe object to search for object)Overrides java. Implements java. |
| protected Set | Returns: a view of the set of entriesCreate a new view for the set of entries in this multiset. |
| protected abstract Iterator | |
| protected Set | Returns: a view of the set of unique elementsCreate a new view for the set of unique elements in this multiset. |
| protected 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 | Returns: the set of entries in this multisetImplements org. |
| public boolean | equals(final Object
the object to compare to object)Overrides java. Implements org. |
| public int | Returns: the number of occurrences of the object, zero if not foundthe object to search for object)Implements org. |
| public int | hashCode()
Overrides java. Implements org. |
| public Iterator | Returns: the iteratorImplements abstract java. Implements org. |
| public boolean | remove(final Object
the object to remove object)Overrides java. Implements org. |
| 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. |
| public boolean | removeAll(final Collection<?>
the collection of elements to remove coll)Overrides java. Implements org. |
| public int | setCount(final E
the object to update object, final int the number of occurrences of the object count)Implements org. |
| public int | Returns: current size of the multisetImplements abstract java. Implements org. |
| public String | Returns: a debugging toStringOverrides java. |
| protected abstract int | Returns: the number of unique elementsReturns the number of unique elements in this multiset. |
| public Set | Returns: the set of unique elements in this multisetImplements org. |
| entrySet | back to summary |
|---|---|
| private transient Set<MultiSet. View of the entries | |
| uniqueSet | back to summary |
|---|---|
| private transient Set<E> uniqueSet View of the elements | |
| AbstractMultiSet | back to summary |
|---|---|
| protected AbstractMultiSet() Constructor needed for subclass serialisation. | |
| add | back to summary |
|---|---|
| public boolean add(final E object) Overrides java. Implements org. Doc from org. Adds one copy of the specified object to the MultiSet.
If the object is already in the
| |
| add | back to summary |
|---|---|
| public int add(final E object, final int occurrences) Implements org. Doc from org. Adds a number of occurrences of the specified object to the MultiSet.
If the object is already in the
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Clears the multiset removing all elements from the entrySet.
| |
| contains | back to summary |
|---|---|
| public boolean contains(final Object object) Overrides java. Implements java. Determines if the multiset contains the given element. | |
| createEntrySet | back to summary |
|---|---|
| protected Set Create a new view for the set of entries in this multiset. | |
| createEntrySetIterator | back to summary |
|---|---|
| protected abstract Iterator Creates an entry set iterator. Subclasses can override this to return iterators with different properties. | |
| createUniqueSet | back to summary |
|---|---|
| protected Set Create a new view for the set of unique elements in this multiset.
| |
| createUniqueSetIterator | back to summary |
|---|---|
| protected Iterator Creates a unique set iterator. Subclasses can override this to return iterators with different properties.
| |
| doReadObject | back to summary |
|---|---|
| protected void doReadObject(final ObjectInputStream in) throws IOException, ClassNotFoundException Read the multiset in using a custom routine.
| |
| doWriteObject | back to summary |
|---|---|
| protected void doWriteObject(final ObjectOutputStream out) throws IOException Write the multiset out using a custom routine.
| |
| entrySet | back to summary |
|---|---|
| public Set Implements org. Returns an unmodifiable view of the entries of this multiset. | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object object) Overrides java. Implements org. Doc from org. 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. | |
| getCount | back to summary |
|---|---|
| public int getCount(final Object object) Implements org. Returns the number of occurrence of the given element in this multiset by iterating over its entrySet. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements org. Doc from org. 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
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements org. Gets an iterator over the multiset elements. Elements present in the MultiSet more than once will be returned repeatedly. | |
| remove | back to summary |
|---|---|
| public boolean remove(final Object object) Overrides java. Implements org. Doc from org. 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 | |
| remove | back to summary |
|---|---|
| public int remove(final Object object, final int occurrences) Implements org. Doc from org. 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. | |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(final Collection<?> coll) Overrides java. Implements org. Doc from org. Remove all occurrences of all elements from this MultiSet represented in the given collection.
| |
| setCount | back to summary |
|---|---|
| public int setCount(final E object, final int count) Implements org. Doc from org. 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
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements org. Returns the number of elements in this multiset.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implement a toString() method suitable for debugging. | |
| uniqueElements | back to summary |
|---|---|
| protected abstract int uniqueElements() Returns the number of unique elements in this multiset.
| |
| uniqueSet | back to summary |
|---|---|
| public Set Implements org. Returns a view of the unique elements of this multiset. | |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(final Object
object to be compared for equality with this multiset entry object)Overrides java. Implements org. |
| public int | hashCode()
Overrides java. Implements org. |
| public String |
| AbstractEntry | back to summary |
|---|---|
| protected AbstractEntry() | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object object) Overrides java. Implements org. Doc from org. 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.getElement()==null ? e2.getElement()==null
: e1.getElement().equals(e2.getElement())) &&
(e1.getCount()==e2.getCount())
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements org. Doc from org. Returns the hash code value for this multiset entry.
The hash code of a multiset entry
(e==null ? 0 : e.hashCode()) ^ noOccurances)
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| private final AbstractMultiSet |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | contains(final Object
element whose presence in this set is to be tested obj)Overrides java. Implements java. true if this set contains the specified element.
|
| public Iterator | iterator()
Implements abstract java. Implements java. |
| public boolean | remove(final Object
object to be removed from this set, if present obj)Overrides java. Implements java. |
| public int | size()
Implements abstract java. Implements java. |
| parent | back to summary |
|---|---|
| private final AbstractMultiSet<E> parent | |
| EntrySet | back to summary |
|---|---|
| protected EntrySet(final AbstractMultiSet<E> parent) Constructs a new view of the MultiSet.
| |
| contains | back to summary |
|---|---|
| public boolean contains(final Object obj) Overrides java. Implements java. Doc from java. Returns | |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. 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). | |
| remove | back to summary |
|---|---|
| public boolean remove(final Object obj) Overrides java. Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element | |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private MultiSet. | |
| private final Iterator | |
| private int | |
| private final AbstractMultiSet |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public E | |
| public void | remove()
Overrides default java. |
| canRemove | back to summary |
|---|---|
| private boolean canRemove | |
| current | back to summary |
|---|---|
| private MultiSet. | |
| entryIterator | back to summary |
|---|---|
| private final Iterator<MultiSet. | |
| itemCount | back to summary |
|---|---|
| private int itemCount | |
| parent | back to summary |
|---|---|
| private final AbstractMultiSet<E> parent | |
| MultiSetIterator | back to summary |
|---|---|
| public MultiSetIterator(final AbstractMultiSet<E> parent) Constructor.
| |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public E next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to 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
| |
| Modifier and Type | Field and Description |
|---|---|
| protected final AbstractMultiSet | parent
The parent multiset |
| Access | Constructor and Description |
|---|---|
| protected | UniqueSet(final AbstractMultiSet<E>
the parent MultiSet parent)Constructs a new unique element view of the MultiSet. |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides java. Implements java. |
| public boolean | contains(final Object
element whose presence in this set is to be tested key)Overrides java. Implements java. 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. Implements java. true if this set contains all of the elements of the
specified collection.
|
| public Iterator | iterator()
Implements abstract java. Implements java. |
| public boolean | remove(final Object
object to be removed from this set, if present key)Overrides java. Implements java. |
| public int | size()
Implements abstract java. Implements java. |
| parent | back to summary |
|---|---|
| protected final AbstractMultiSet<E> parent The parent multiset | |
| UniqueSet | back to summary |
|---|---|
| protected UniqueSet(final AbstractMultiSet<E> parent) Constructs a new unique element view of the MultiSet.
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Doc from java. Removes all of the elements from this set (optional operation). The set will be empty after this call returns.
| |
| contains | back to summary |
|---|---|
| public boolean contains(final Object key) Overrides java. Implements java. Doc from java. Returns | |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(final Collection<?> coll) Overrides java. Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements abstract java. Implements java. Doc from java. 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). | |
| remove | back to summary |
|---|---|
| public boolean remove(final Object key) Overrides java. Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element | |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |