Class AbstractMultiSet.MultiSetIteratorImpl<T>

    • Constructor Detail

      • MultiSetIteratorImpl

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

      • hasNext

        public final boolean hasNext()
        Specified by:
        hasNext in interface 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 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 Iterator<T>
        Specified by:
        remove in interface MultiSetIterator<T>
        Throws:
        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.
      • 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:
        UnsupportedOperationException - this implementation does not throw the exception but the iterator of an immutable multi set of course do.
        See Also:
        MultiSetIterator.remove()