Class QueueReader<E>

java.lang.Object
qilin.util.queue.QueueReader<E>
All Implemented Interfaces:
Iterator<E>

public class QueueReader<E> extends Object implements Iterator<E>
A queue of Object's. One can add objects to the queue, and they are later read by a QueueReader. One can create arbitrary numbers of QueueReader's for a queue, and each one receives all the Object's that are added. Only objects that have not been read by all the QueueReader's are kept. A QueueReader only receives the Object's added to the queue after the QueueReader was created.
Author:
Ondrej Lhotak
  • Field Details

    • q

      protected E[] q
    • index

      protected int index
  • Constructor Details

    • QueueReader

      protected QueueReader(E[] q, int index)
  • Method Details

    • next

      public E next()
      Returns (and removes) the next object in the queue, or null if there are none.
      Specified by:
      next in interface Iterator<E>
    • skip

      protected boolean skip(Object ret)
    • hasNext

      public boolean hasNext()
      Returns true iff there is currently another object in the queue.
      Specified by:
      hasNext in interface Iterator<E>
    • remove

      public void remove(E o)
      Removes an element from the underlying queue. This operation can only delete elements that have not yet been consumed by this reader.
      Parameters:
      o - The element to remove
    • remove

      public void remove(Collection<E> toRemove)
      Removes elements from the underlying queue. This operation can only delete elements that have not yet been consumed by this reader.
      Parameters:
      toRemove - The elements to remove
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<E>
    • clone

      public QueueReader<E> clone()
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object