Interface Feed<T>

All Superinterfaces:
Iterable<T>
All Known Subinterfaces:
Deque<T>, Queue<T>, Stack<T>

public interface Feed<@Out T> extends Iterable<T>
Common superinterface for stack and queue. Feed can be iterated over but doing so changes its state, i.e. every item returned by iterator is removed from the feed.
Since:
2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all elements from the feed.
    boolean
    Returns true if the feed is empty.
    State changing iterator of this feed.
    default boolean
    Returns true if the feed is non-empty.
    Returns top element from the feed without removing it.
    Removes top element from the feed and returns it.

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Method Details

    • isEmpty

      boolean isEmpty()
      Returns true if the feed is empty.
    • nonEmpty

      default boolean nonEmpty()
      Returns true if the feed is non-empty.
    • clear

      void clear()
      Removes all elements from the feed.
    • take

      T take() throws NoSuchElementException
      Removes top element from the feed and returns it.
      Throws:
      NoSuchElementException - if the feed is empty.
    • peek

      T peek() throws NoSuchElementException
      Returns top element from the feed without removing it.
      Throws:
      NoSuchElementException - if the feed is empty.
    • iterator

      Iterator<T> iterator()
      State changing iterator of this feed. Elements produced by the iterator are removed from this feed. Specifically Iterator.next() has the same effect as calling take(). The iterator does not implement remove() since element returned is already removed from the feed.
      Specified by:
      iterator in interface Iterable<T>