Package com.complexible.common.collect

# Class MarkResetSkippingIterator<T>

java.lang.Object
com.complexible.common.collect.AbstractSkippingIterator<T>
com.complexible.common.collect.MarkResetSkippingIterator<T>

All Implemented Interfaces:
  `CloseableIterator<T>`, `Copyable<MarkResetIterator<T>>`, `MarkResetIterator<T>`, `PeekingSkippingIterator<T>`, `ResettableIterator<T>`, `RestrictedMarkResetIterator<T>`, `SkippingIterator<T>`, `com.google.common.collect.PeekingIterator<T>`, `AutoCloseable`, `Iterator<T>`

public class MarkResetSkippingIterator<T> extends AbstractSkippingIterator<T> implements RestrictedMarkResetIterator<T>
Implements the `mark-reset behavior` via `ResettableIterator.reset()` and `SkippingIterator.skipTo(Object)`. Note: this class does not `CloseableIterator.close()` the argument iterator. The class supports restrictions on the underlying iterator, for example, to make sure that it doesn't get out of a specific value range.

Since:
  8.0
Author:
  Pavel Klinov

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface com.complexible.common.base.CloseableIterator

  `CloseableIterator.AbstractCloseableIterator<T>, CloseableIterator.DelegatingCloseableIterator<T>, CloseableIterator.EmptyCloseableIterator<T>`

- ## Field Summary

  ### Fields inherited from class com.complexible.common.collect.AbstractSkippingIterator

  `mComparator`

  ### Fields inherited from interface com.complexible.common.collect.SkippingIterator

  `UNKNOWN_SIZE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MarkResetSkippingIterator(PeekingSkippingIterator<T> theIterator)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected T`
  `computeNext()`
  Return the next element to be returned by the iterator
  `protected T`
  `computeSkipTo(T theTarget)`
  Returns the element that this iteration has skipped to or `null` if it ran off the end.
  `MarkResetSkippingIterator<T>`
  `copy()`
  Create a deep copy of the object which does not share any references with the original.
  `void`
  `mark(T mark)`
  Creates a mark from the provided element.
  `protected void`
  `performReset()`
  `void`
  `resetToMark()`
  Rewinds the position of the iterator to the previously marked element.
  `void`
  `restrict(Predicate<T> restriction)`

  ### Methods inherited from class com.complexible.common.collect.AbstractSkippingIterator

  `assertOpen, close, comparator, computeSkipTo, endOfData, estimatedSize, hasNext, isClosed, isLessOrEqualThan, next, peek, remove, reset, resetState, skipTo, skipTo, validateSkipTarget`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.complexible.common.base.CloseableIterator

  `close`

  ### Methods inherited from interface java.util.Iterator

  `forEachRemaining, hasNext`

  ### Methods inherited from interface com.complexible.common.collect.ResettableIterator

  `reset`

- ## Constructor Details

  - ### MarkResetSkippingIterator

    public MarkResetSkippingIterator(PeekingSkippingIterator<T> theIterator)

- ## Method Details

  - ### restrict

    public void restrict(Predicate<T> restriction)
    Specified by:
      `restrict` in interface `RestrictedMarkResetIterator<T>`

  - ### computeNext

    protected T computeNext()
    Description copied from class: `AbstractSkippingIterator`
    Return the next element to be returned by the iterator
    Specified by:
      `computeNext` in class `AbstractSkippingIterator<T>`
    Returns:
      the next element

  - ### computeSkipTo

    protected T computeSkipTo(T theTarget)
    Description copied from class: `AbstractSkippingIterator`
    Returns the element that this iteration has skipped to or `null` if it ran off the end.
    Specified by:
      `computeSkipTo` in class `AbstractSkippingIterator<T>`
    Parameters:
      `theTarget` - the skipping target
    Returns:
      the first element that is greater or equal to the skipping target, or `null` if it doesn't exist.

  - ### performReset

    protected void performReset()
    Specified by:
      `performReset` in class `AbstractSkippingIterator<T>`

  - ### mark

    public void mark(T mark)
    Description copied from interface: `MarkResetIterator`
    Creates a mark from the provided element.
    Specified by:
      `mark` in interface `MarkResetIterator<T>`

  - ### resetToMark

    public void resetToMark()
    Description copied from interface: `MarkResetIterator`
    Rewinds the position of the iterator to the previously marked element.
    Specified by:
      `resetToMark` in interface `MarkResetIterator<T>`

  - ### copy

    public MarkResetSkippingIterator<T> copy()
    Description copied from interface: `Copyable`
    Create a deep copy of the object which does not share any references with the original.
    Specified by:
      `copy` in interface `Copyable<T>`
    Specified by:
      `copy` in interface `RestrictedMarkResetIterator<T>`
    Returns:
      a copy of the object