Interface MultiSetIterator<E>
-
- Type Parameters:
E- the class of the elements of this multi-set. Created: Fri Oct 3 21:37:29 2014
- All Superinterfaces:
java.util.Iterator<E>
- All Known Implementing Classes:
AbstractMultiSet.MultiSetIteratorImpl
public interface MultiSetIterator<E> extends java.util.Iterator<E>Generalization of iterator suitable e.g. for sets toMultiSets. Needed in addition: methods on multiplicity of element read last.Not clear whether one should not allow addMult. why not unify addMult and removeMult? This would require a different implementation. Problem is also that
MultiSetis not (yet) a collection.- Version:
- 1.0
- Author:
- Ernst Reissner
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetMult()Returns the current multiplicity of the element last read byIterator.next(), provided that element was not removed in the meantime.MultiSet.MultiplicitygetMultObj()voidremove()Removes from the underlyingMultiSetthe last element returned byIterator.next(), provided that element was not removed in the meantime and this method is supported by this iterator.intremoveMult(int removeMult)Removes from the underlyingMultiSetthe last element returned by invocation ofIterator.next()with multiplicity given byremoveMult, provided that element was not removed in the meantime and this method is supported by this iterator.intsetMult(int setMult)Endows the element of the underlyingMultiSetreturned by the last invocation ofIterator.next()with multiplicity given bysetMult, provided that element was not removed in the meantime and this method is supported by this iterator.
-
-
-
Method Detail
-
remove
void remove()
Removes from the underlyingMultiSetthe last element returned byIterator.next(), provided that element was not removed in the meantime and this method is supported by this iterator.Invoking this method removes that element from the set associated with
MultiSet. After this, neithersetMult(int)norremoveMult(int)norgetMult()may be invoked before next invocation ofIterator.next().The behavior of this iterator is unspecified if the underlying
MultiSetis modified while the iteration is in progress in any way other than by calling methods of an iterator.- Specified by:
removein interfacejava.util.Iterator<E>- Throws:
java.lang.UnsupportedOperationException- if removing is not supported by this iterator. This is in particular true if the underlyingMultiSetis immutable.java.lang.IllegalStateException- provided this method is supported by this iterator: if the methodIterator.next()has not yet been called or if, after last invocation ofIterator.next()the element returned by this invocation has been removed from the underlyingMultiSetinvokingremove(),setMult(int)orremoveMult(int)or a combination in an appropriate way.
-
getMult
int getMult()
Returns the current multiplicity of the element last read byIterator.next(), provided that element was not removed in the meantime. This multiplicity could have been modified after last invocation ofIterator.next()by invokingremove(),setMult(int)orremoveMult(int). If the multiplicity became zero, this means that it has been completely removed and so its multiplicity cannot be queried any more.- Returns:
- the multiplicity of the element this method refers to. This is a positive integer.
- Throws:
java.lang.IllegalStateException- if the methodIterator.next()has not yet been called or if, after last invocation ofIterator.next()the element returned by this invocation has been removed from the underlyingMultiSetinvokingremove(),setMult(int)orremoveMult(int)or a combination in an appropriate way.
-
getMultObj
MultiSet.Multiplicity getMultObj()
-
setMult
int setMult(int setMult)
Endows the element of the underlyingMultiSetreturned by the last invocation ofIterator.next()with multiplicity given bysetMult, 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 withMultiSet. After this, neithersetMult(int)norremoveMult(int)norremove()norgetMult()may be invoked before next invocation ofIterator.next().The behavior of this iterator is unspecified if the underlying
MultiSetis modified while the iteration is in progress in any way other than by calling methods of an iterator.- Parameters:
setMult- a non-negative number signifying the new multiplicity of the element read last byIterator.next().- Returns:
- the multiplicity of the element this method refers to before invoking this method.
- Throws:
java.lang.UnsupportedOperationException- if setting multiplicity is not supported by this iterator. This is in particular true if the underlyingMultiSetis immutable.java.lang.IllegalStateException- provided this method is supported by this iterator: if the methodIterator.next()has not yet been called or if, after last invocation ofIterator.next()the element returned by this invocation has been removed from the underlyingMultiSetinvokingremove(),setMult(int)orremoveMult(int)or a combination in an appropriate way.java.lang.IllegalArgumentException- ifsetMultis negative and if the abovementioned exceptions are not thrown.
-
removeMult
int removeMult(int removeMult)
Removes from the underlyingMultiSetthe last element returned by invocation ofIterator.next()with multiplicity given byremoveMult, provided that element was not removed in the meantime and this method is supported by this iterator.If
removeMultis the multiplicity of that element, invoking this method removes that element from the set associated withMultiSet. After this, neithersetMult(int)norremove()norremove()norgetMult()may be invoked before next invocation ofIterator.next().The behavior of this iterator is unspecified if the underlying
MultiSetis modified while the iteration is in progress in any way other than by calling methods of an iterator.- Parameters:
removeMult- a number signifying the multiplicity which which the current element should be removed. Negative values signify adding that element.- Returns:
- the multiplicity of the element this method refers to before invoking this method.
- Throws:
java.lang.UnsupportedOperationException- if removing multiplicity is not supported by this iterator. This is in particular true if the underlyingMultiSetis immutable.java.lang.IllegalStateException- if the methodIterator.next()has not yet been called or if, after last invocation ofIterator.next()the element returned by this invocation has been removed from the underlyingMultiSetinvokingremove(),setMult(int)orremoveMult(int)or a combination in an appropriate way.java.lang.IllegalArgumentException- ifremoveMultor resulting multiplicity is negative and if the abovementioned exceptions are not thrown.- See Also:
remove()
-
-