Class CircularArrayBase
java.lang.Object
org.ddogleg.struct.CircularArrayBase
- Direct Known Subclasses:
CircularArray, CircularArray_F32, CircularArray_F64, CircularArray_I32, CircularArray_I64, CircularArray_I8
Base class for Circular Arrays
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintarrayIndex(int index) Converts circular index into the inner array indexabstract intNumber of elements in the inner arrayabstract <T> TReference to the inner arraybooleanisEmpty()If no elements are used in the arraybooleanisFull()If all available elements are usedvoidremove(int index) Removes an element.final voidRemoves the first element.final voidRemoves the last element.final voidreset()protected abstract voidshiftElements(int src0, int dst0, int length) Copies the value in the src into dst inside the inner array.intsize()Number of elements used in the array
-
Field Details
-
start
public int startindex which is the start of the queue -
size
public int sizenumber 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
-