Interface PeekingIterator<T>

Type Parameters:
T - the type of elements returned by this iterator
All Known Subinterfaces:
ParameterIterator, ParchiveIterator<T>
All Known Implementing Classes:
AggrrayIterator, MultiSegmentIterator, SegmentIterator, SimpleParameterIterator

public interface PeekingIterator<T>
An interface for an iterator that allows peeking at the current value.

The advantage over the standard java iterator is that because the value can be looked at, it can be used in priority queues to run multiple of them in parallel.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the iterator has more elements.
    void
    Moves the iterator to the next element.
    Returns the current value from the iterator without advancing.
  • Method Details

    • isValid

      boolean isValid()
      Returns true if the iterator has more elements.

      This method allows to verify whether the iterator has a valid value to be fetched.

      Returns:
      true if the iterator has more elements or false otherwise
    • value

      T value()
      Returns the current value from the iterator without advancing.

      This method can only be called if isValid() returns true. If called after isValid() returns false, this method will throw an exception.

      Returns:
      the current element
      Throws:
      IllegalStateException - if isValid() returns false
    • next

      void next()
      Moves the iterator to the next element.

      If isValid() returns false, calling this method has no effect.