Class RemovableIterator<C>

  • All Implemented Interfaces:
    Iterator<C>
    Direct Known Subclasses:
    RemovableCloseableIterator

    public class RemovableIterator<C>
    extends Object
    implements Iterator<C>
    An Iterator implementation that allows for a Iterator that doesn't allow remove operations to implement remove by delegating the call to the provided consumer to remove the previously read value.
    Since:
    9.1
    Author:
    wburns
    • Field Detail

      • realIterator

        protected final Iterator<C> realIterator
      • consumer

        protected final Consumer<? super C> consumer
      • previousValue

        protected C previousValue
      • currentValue

        protected C currentValue
    • Constructor Detail

      • RemovableIterator

        public RemovableIterator​(Iterator<C> realIterator,
                                 Consumer<? super C> consumer)
    • Method Detail

      • getNextFromIterator

        protected C getNextFromIterator()
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface Iterator<C>
      • next

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

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