Class AbstractMultiSet.MultiSetIteratorImpl<T>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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()
      Removes from the underlying MultiSet the last element returned by next(), provided that element was not removed in the meantime and this method is supported by this iterator.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • last

        private java.util.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 Detail

      • MultiSetIteratorImpl

        MultiSetIteratorImpl​(MultiSet<T> multiSet)
    • Method Detail

      • hasNext

        public final boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T>
      • next

        public final 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.
        Specified by:
        next in interface java.util.Iterator<T>
      • remove

        public final void remove()
        Removes from the underlying 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.
        Specified by:
        remove in interface java.util.Iterator<T>
        Specified by:
        remove in interface MultiSetIterator<T>
        Throws:
        java.lang.UnsupportedOperationException - this implementation does not throw the exception but the iterator of an immutable multi set of course do.
      • getMult

        public final int getMult()
        Returns the current multiplicity of the element last read by next(), provided that element was not removed in the meantime.
        Specified by:
        getMult in interface MultiSetIterator<T>
        Returns:
        the multiplicity of the element this method refers to. This is a positive integer.
      • setMult

        public final int setMult​(int mult)
        Description copied from interface: MultiSetIterator
        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.

        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.

        Specified by:
        setMult in interface MultiSetIterator<T>
        Parameters:
        mult - a non-negative number signifying the new multiplicity of the element read last by Iterator.next().
        Returns:
        the multiplicity of the element this method refers to before invoking this method.
        Throws:
        java.lang.UnsupportedOperationException - this implementation does not throw the exception but the iterator of an immutable multi set of course do.
      • removeMult

        public final int removeMult​(int mult)
        Description copied from interface: MultiSetIterator
        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.

        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.

        Specified by:
        removeMult in interface MultiSetIterator<T>
        Parameters:
        mult - 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 - this implementation does not throw the exception but the iterator of an immutable multi set of course do.
        See Also:
        MultiSetIterator.remove()