Class CircularArrayBase

java.lang.Object
org.ddogleg.struct.CircularArrayBase
Direct Known Subclasses:
CircularArray, CircularArray_F32, CircularArray_F64, CircularArray_I32, CircularArray_I64, CircularArray_I8

public abstract class CircularArrayBase extends Object
Base class for Circular Arrays
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    number of elements in the queue
    int
    index which is the start of the queue
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    arrayIndex(int index)
    Converts circular index into the inner array index
    abstract int
    Number of elements in the inner array
    abstract <T> T
    Reference to the inner array
    boolean
    If no elements are used in the array
    boolean
    If all available elements are used
    void
    remove(int index)
    Removes an element.
    final void
    Removes the first element.
    final void
    Removes the last element.
    final void
     
    protected abstract void
    shiftElements(int src0, int dst0, int length)
    Copies the value in the src into dst inside the inner array.
    int
    Number of elements used in the array

    Methods inherited from class Object

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

    • start

      public int start
      index which is the start of the queue
    • size

      public int size
      number of elements in the queue
  • Constructor Details

    • CircularArrayBase

      public CircularArrayBase()
  • Method Details

    • reset

      public final void reset()
    • removeHead

      public final void removeHead()
      Removes the first element. O(1) complexity
    • removeTail

      public final void removeTail()
      Removes the last element. O(1) complexity
    • remove

      public void remove(int index)
      Removes an element. O(N) complexity.
    • size

      public int size()
      Number of elements used in the array
    • isEmpty

      public boolean isEmpty()
      If no elements are used in the array
    • isFull

      public boolean isFull()
      If all available elements are used
    • shiftElements

      protected abstract void shiftElements(int src0, int dst0, int length)
      Copies the value in the src into dst inside the inner array. Needs to handle wrap around
    • arrayIndex

      public int arrayIndex(int index)
      Converts circular index into the inner array index
    • getMaxSize

      public abstract int getMaxSize()
      Number of elements in the inner array
    • innerArray

      public abstract <T> T innerArray()
      Reference to the inner array