Class ModifiableCollectionSizedIterator<M>

  • Type Parameters:
    M - is the type of element.
    All Implemented Interfaces:
    Iterator<M>, SizedIterator<M>

    public class ModifiableCollectionSizedIterator<M>
    extends Object
    implements SizedIterator<M>
    Sized iterator on a collection that can be changed through the iterator.

    A sized iterator is an Iterator that is able to reply the size of the iterated collection and the number of elements that may be encountered in the next iterations.

    This iterator enables the use of the function remove(). See UnmodifiableCollectionSizedIterator for an sized iterator that disables this function.

    Version:
    17.0 2020-01-04 14:41:38
    Author:
    Stéphane GALLAND
    See Also:
    UnmodifiableCollectionSizedIterator
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    util
    • Constructor Detail

      • ModifiableCollectionSizedIterator

        public ModifiableCollectionSizedIterator​(Collection<M> collection)
        Construct an iterator.
        Parameters:
        collection - the collection to iterate on.
      • ModifiableCollectionSizedIterator

        public ModifiableCollectionSizedIterator​(Collection<M> collection,
                                                 ModifiableCollectionSizedIteratorOwner<M> owner)
        Construct an iterator.
        Parameters:
        collection - the collection to iterate on.
        owner - the owner of the iterator.
    • Method Detail

      • rest

        @Pure
        public int rest()
        Description copied from interface: SizedIterator
        Replies the count of elements which are not replied by the iterator.
        Specified by:
        rest in interface SizedIterator<M>
        Returns:
        the count of elements which are not replied by the iterator.
      • index

        @Pure
        public int index()
        Description copied from interface: SizedIterator
        Replies the position of the last replied element in the iterated collection.
        Specified by:
        index in interface SizedIterator<M>
        Returns:
        the index of the last element replied by next().
      • totalSize

        @Pure
        public int totalSize()
        Description copied from interface: SizedIterator
        Replies the count of elements in the iterated collection.
        Specified by:
        totalSize in interface SizedIterator<M>
        Returns:
        the count of elements in the iterated collection.
      • hasNext

        @Pure
        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<M>
      • next

        public M next()
        Specified by:
        next in interface Iterator<M>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<M>