Package generic.util

# Class AbstractPeekableIterator<T>

java.lang.Object
generic.util.AbstractPeekableIterator<T>

Type Parameters:
  `T` - the type of elements

All Implemented Interfaces:
  `PeekableIterator<T>`, `Iterator<T>`

Direct Known Subclasses:
  `CachedAddressSetView.CachedRangeIterator`, `DBTraceProgramViewSymbolTable.PrimarySymbolIterator`, `DistinctIterator`, `OverlappingObjectIterator`, `TraceViewportSpanIterator`, `TwoWayBreakdownAddressRangeIterator`, `UnionAddressRangeIterator`, `WrappingPeekableIterator`

public abstract class AbstractPeekableIterator<T> extends Object implements PeekableIterator<T>
An implementation of `PeekableIterator` that only requires a way to seek out the next element. This will keep that element in hand until the next element is actually requested by the client. This does not invoke the search until the next element is required, either because the client called next or else wants to peek at it.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected T`
  `next`
  `protected boolean`
  `soughtNext`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractPeekableIterator()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `hasNext()`
  `T`
  `next()`
  `T`
  `peek()`
  Returns the item that would be returned by calling `Iterator.next()`, but without incrementing the iterator.
  `protected abstract T`
  `seekNext()`
  Find the next element in this iterator, because the client called either `next` or `peek()`.

  ### 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, remove`

- ## Field Details

  - ### next

    protected T next

  - ### soughtNext

    protected boolean soughtNext

- ## Constructor Details

  - ### AbstractPeekableIterator

    public AbstractPeekableIterator()

- ## Method Details

  - ### seekNext

    protected abstract T seekNext()
    Find the next element in this iterator, because the client called either `next` or `peek()`.
    Returns:
      the next element

  - ### hasNext

    public boolean hasNext()
    Specified by:
      `hasNext` in interface `Iterator<T>`

  - ### next

    public T next()
    Specified by:
      `next` in interface `Iterator<T>`

  - ### peek

    public T peek() throws NoSuchElementException
    Description copied from interface: `PeekableIterator`
    Returns the item that would be returned by calling `Iterator.next()`, but without incrementing the iterator.
    Specified by:
      `peek` in interface `PeekableIterator<T>`
    Returns:
      the item that would be returned by calling `Iterator.next()`
    Throws:
      `NoSuchElementException` - if there is no element to peek at