Class Dequeue

java.lang.Object
com.tangosol.util.Base
com.tangosol.util.Dequeue
All Implemented Interfaces:
Serializable, Cloneable, Enumeration, Iterator

public class Dequeue extends Base implements Enumeration, Iterator, Cloneable, Serializable
Represents a double-ended queue (dequeue) of objects. A dequeue allows items which have been removed from the front of the queue to be put back on the front of the queue.
Version:
1.00, 12/05/96
Author:
Cameron Purdy
See Also:
  • Constructor Details

    • Dequeue

      public Dequeue()
      Constructs a dequeue.
  • Method Details

    • hasMoreElements

      public boolean hasMoreElements()
      Determines if the Dequeue contains more elements.
      Specified by:
      hasMoreElements in interface Enumeration
      Returns:
      true if Dequeue contains more elements, false otherwise
    • nextElement

      public Object nextElement() throws NoSuchElementException
      Returns the next element from the Dequeue. Calls to this method will enumerate successive elements.
      Specified by:
      nextElement in interface Enumeration
      Returns:
      the next element
      Throws:
      NoSuchElementException - If no more elements exist.
    • hasNext

      public boolean hasNext()
      Tests if this Iterator contains more elements.
      Specified by:
      hasNext in interface Iterator
      Returns:
      true if the Iterator contains more elements, false otherwise
    • next

      public Object next()
      Returns the next element of this Iterator.
      Specified by:
      next in interface Iterator
      Returns:
      the next element in the Iterator
    • remove

      public void remove()
      Remove the last-returned element that was returned by the Iterator. This method always throws UnsupportedOperationException because the Iterator is immutable.
      Specified by:
      remove in interface Iterator
    • addElement

      public void addElement(Object o)
      Adds an element to the dequeue. The passed object is placed at the end of the dequeue.
      Parameters:
      o - object to add to the Dequeue
    • putBackElement

      public void putBackElement(Object o)
      Returns the most recently returned element to the Dequeue. After calling this method, a call to nextElement will return the element that was returned by the most recent call to nextElement. This method can be called multiple times to put back multiple elements.
      Parameters:
      o - the object
      Throws:
      NoSuchElementException - If the element that is being put back is no longer in the Dequeue.
    • removeAllElements

      public void removeAllElements()
      Removes all items from the dequeue.
    • capacity

      public int capacity()
      Determine the current capacity of this dequeue.
      Returns:
      the current capacity of this dequeue
    • size

      public int size()
      Determine the current number of objects in this dequeue.
      Returns:
      the current number of objects in this dequeue
    • isEmpty

      public boolean isEmpty()
      Determines if the dequeue is empty.
      Returns:
      true if the dequeue is empty, false otherwise
    • isFull

      public boolean isFull()
      Determines if the dequeue is full. This method is mainly of use internally, since the dequeue auto-resizes when additional items are added.
      Returns:
      true if the dequeue is full, false otherwise
    • clone

      public Object clone()
      Creates a clone of the dequeue.
      Overrides:
      clone in class Object
      Returns:
      the clone
    • next

      protected int next(int i)
      Determines the index following the passed index for storing or accessing an item from the m_ao storage.
      Parameters:
      i - the index
      Returns:
      the next index
    • prev

      protected int prev(int i)
      Determines the index preceding the passed index for storing or accessing an item from the m_ao storage.
      Parameters:
      i - the index
      Returns:
      the previous index
    • grow

      protected void grow()
      Increase the capacity of the Dequeue.