Class CircularArray_I32

java.lang.Object
org.ddogleg.struct.CircularArray_I32

public class CircularArray_I32 extends Object
A circular queue which can grow as needed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int[]
     
    int
     
    int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    CircularArray_I32(int dataSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int value)
    Adds a new element to the queue.
    void
    addW(int value)
    Adds a new element to the queue, but if the queue is full write over the oldest element.
    int
    get(int index)
    Returns the element in the queue at index.
    int
    Value of the first element in the queue
    boolean
     
    boolean
     
    int
    Returns and removes the first element from the queue.
    int
    Returns and removes the last element from the queue.
    void
    Removes the first element
    void
    Removes the last element
    void
     
    int
     
    int
    Value of the last element in the queue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • data

      public int[] data
    • start

      public int start
    • size

      public int size
  • Constructor Details

    • CircularArray_I32

      public CircularArray_I32()
    • CircularArray_I32

      public CircularArray_I32(int dataSize)
  • Method Details

    • reset

      public void reset()
    • popHead

      public int popHead()
      Returns and removes the first element from the queue.
      Returns:
      first element in the queue
    • popTail

      public int popTail()
      Returns and removes the last element from the queue.
      Returns:
      last element in the queue
    • head

      public int head()
      Value of the first element in the queue
    • tail

      public int tail()
      Value of the last element in the queue
    • removeHead

      public void removeHead()
      Removes the first element
    • removeTail

      public void removeTail()
      Removes the last element
    • get

      public int get(int index)
      Returns the element in the queue at index. No bounds check is performed and a garbage value might be returned.
      Parameters:
      index - Which element in the queue you wish to access
      Returns:
      the element's value
    • add

      public void add(int value)
      Adds a new element to the queue. If the queue isn't large enough to store this value then its internal data array will grow
      Parameters:
      value - Value which is to be added
    • addW

      public void addW(int value)
      Adds a new element to the queue, but if the queue is full write over the oldest element.
      Parameters:
      value - Value which is to be added
    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
    • isFull

      public boolean isFull()