Class CircularArray_I64
java.lang.Object
org.ddogleg.struct.CircularArrayBase
org.ddogleg.struct.CircularArray_I64
A circular array for primitive type long which can grow as needed.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class CircularArrayBase
size, start -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long value) Adds a new element to the queue.voidaddW(long value) Adds a new element to the queue, but if the queue is full write over the oldest element.copy()longget(int index) Returns the element in the queue at index.intNumber of elements in the inner arraylonghead()Value of the first element in the queueintindexOf(int offset, CircularArray_I64.Match condition) Searches for the next element starting at index "offset" that the passed in condition is true for.<T> TReference to the inner arraylongpopHead()Returns and removes the first element from the queue.longpopTail()Returns and removes the last element from the queue.voidresizeQueue(int maxSize) Changes the size of the inner array.setTo(CircularArray_I64 original) protected voidshiftElements(int src0, int dst0, int length) Copies the value in the src into dst inside the inner array.longtail()Value of the last element in the queueMethods inherited from class CircularArrayBase
arrayIndex, isEmpty, isFull, remove, removeHead, removeTail, reset, size
-
Field Details
-
data
public long[] dataInternal array that stores elements
-
-
Constructor Details
-
CircularArray_I64
public CircularArray_I64() -
CircularArray_I64
public CircularArray_I64(int dataSize)
-
-
Method Details
-
indexOf
Searches for the next element starting at index "offset" that the passed in condition is true for. Returns -1 if no match was found -
popHead
public long popHead()Returns and removes the first element from the queue.- Returns:
- first element in the queue
-
popTail
public long popTail()Returns and removes the last element from the queue.- Returns:
- last element in the queue
-
head
public long head()Value of the first element in the queue -
tail
public long tail()Value of the last element in the queue -
get
public long 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(long 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(long 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
-
setTo
-
copy
-
resizeQueue
public void resizeQueue(int maxSize) Changes the size of the inner array. Does not save old values. -
shiftElements
protected void shiftElements(int src0, int dst0, int length) Description copied from class:CircularArrayBaseCopies the value in the src into dst inside the inner array. Needs to handle wrap around- Specified by:
shiftElementsin classCircularArrayBase
-
getMaxSize
public int getMaxSize()Description copied from class:CircularArrayBaseNumber of elements in the inner array- Specified by:
getMaxSizein classCircularArrayBase
-
innerArray
public <T> T innerArray()Description copied from class:CircularArrayBaseReference to the inner array- Specified by:
innerArrayin classCircularArrayBase
-