T - the class of the elements of the underlying multi-set.protected static class AbstractMultiSet.MultiSetIteratorImpl<T> extends Object implements MultiSetIterator<T>
MultiSetIterator
defining also the methods modifying the underlying MultiSet,
namely remove(), setMult(int)
and removeMult(int).| Modifier and Type | Field and Description |
|---|---|
private Iterator<Map.Entry<T,MultiSet.Multiplicity>> |
entrySetIter
An iterator on the entries
of the map
AbstractMultiSet.obj2mult
associating each element of the underlying MultiSet
with its multiplicity. |
private Map.Entry<T,MultiSet.Multiplicity> |
last
The element returned last by invoking
next()
in the iterator entrySetIter
or null if next() has not yet been invoked
or the element returned by the last invocation of next()
has been removed in the meantime
invoking a method of this iterator (instance). |
| Constructor and Description |
|---|
MultiSetIteratorImpl(MultiSet<T> multiSet) |
| Modifier and Type | Method and Description |
|---|---|
int |
getMult()
Returns the current multiplicity of the element
last read by
next(),
provided that element was not removed in the meantime. |
MultiSet.Multiplicity |
getMultObj() |
boolean |
hasNext() |
T |
next()
Returns the next element in the iteration
and, as a side effect, sets
last
with the mapping of that element to its current multiplicity. |
void |
remove()
|
int |
removeMult(int mult)
Removes from the underlying
MultiSet
the last element returned by invocation of Iterator.next()
with multiplicity given by removeMult,
provided that element was not removed in the meantime
and this method is supported by this iterator. |
int |
setMult(int mult)
Endows the element of the underlying
MultiSet
returned by the last invocation of Iterator.next()
with multiplicity given by setMult,
provided that element was not removed in the meantime
and this method is supported by this iterator. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingprivate final Iterator<Map.Entry<T,MultiSet.Multiplicity>> entrySetIter
AbstractMultiSet.obj2mult
associating each element of the underlying MultiSet
with its multiplicity.private Map.Entry<T,MultiSet.Multiplicity> last
next()
in the iterator entrySetIter
or null if next() has not yet been invoked
or the element returned by the last invocation of next()
has been removed in the meantime
invoking a method of this iterator (instance).public final T next()
last
with the mapping of that element to its current multiplicity.public final void remove()
MultiSet
the last element returned by next(),
provided that element was not removed in the meantime
and this method is supported by this iterator.
As a side effect, sets last to null
indicating that this element has been removed.remove in interface MultiSetIterator<T>remove in interface Iterator<T>UnsupportedOperationException - this implementation does not throw the exception
but the iterator of an immutable multi set of course do.public final int getMult()
next(),
provided that element was not removed in the meantime.getMult in interface MultiSetIterator<T>public final MultiSet.Multiplicity getMultObj()
getMultObj in interface MultiSetIterator<T>public final int setMult(int mult)
MultiSetIteratorMultiSet
returned by the last invocation of Iterator.next()
with multiplicity given by setMult,
provided that element was not removed in the meantime
and this method is supported by this iterator.
For setMult=0, invoking this method removes that element
from the set associated with MultiSet.
After this, neither MultiSetIterator.setMult(int) nor MultiSetIterator.removeMult(int)
nor MultiSetIterator.remove() nor MultiSetIterator.getMult() may be invoked
before next invocation of Iterator.next().
The behavior of this iterator is unspecified
if the underlying MultiSet is modified
while the iteration is in progress
in any way other than by calling methods of an iterator.
setMult in interface MultiSetIterator<T>mult - a non-negative number signifying the new multiplicity
of the element read last by Iterator.next().UnsupportedOperationException - this implementation does not throw the exception
but the iterator of an immutable multi set of course do.public final int removeMult(int mult)
MultiSetIteratorMultiSet
the last element returned by invocation of Iterator.next()
with multiplicity given by removeMult,
provided that element was not removed in the meantime
and this method is supported by this iterator.
If removeMult is the multiplicity of that element,
invoking this method removes that element
from the set associated with MultiSet.
After this, neither MultiSetIterator.setMult(int) nor MultiSetIterator.remove()
nor MultiSetIterator.remove() nor MultiSetIterator.getMult() may be invoked
before next invocation of Iterator.next().
The behavior of this iterator is unspecified
if the underlying MultiSet is modified
while the iteration is in progress
in any way other than by calling methods of an iterator.
removeMult in interface MultiSetIterator<T>mult - a number signifying the multiplicity which which
the current element should be removed.
Negative values signify adding that element.UnsupportedOperationException - this implementation does not throw the exception
but the iterator of an immutable multi set of course do.MultiSetIterator.remove()Copyright © 2012–2018 Simuline Organization (l2r). All rights reserved.