Class CircularArray<T>
java.lang.Object
org.ddogleg.struct.CircularArrayBase
org.ddogleg.struct.CircularArray<T>
A circular queue which can grow as needed.
-
Field Summary
FieldsFields inherited from class CircularArrayBase
size, start -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new element to the queue.voidAdds a new element to the queue, but if the queue is full write over the oldest element.protected Tget(int index) Returns the element in the queue at index.intNumber of elements in the inner arraygrow()Adds a new element to the end of the list and returns it.growW()Adds a new element to the end of the list and returns it.head()Value of the first element in the queue<A> AReference to the inner arraypopHead()Returns and removes the first element from the queue.popTail()Returns and removes the last element from the queue.protected voidshiftElements(int src0, int dst0, int length) Copies the value in the src into dst inside the inner array.tail()Value of the last element in the queueMethods inherited from class CircularArrayBase
arrayIndex, isEmpty, isFull, remove, removeHead, removeTail, reset, size
-
Field Details
-
data
-
-
Constructor Details
-
CircularArray
-
CircularArray
-
-
Method Details
-
popHead
Returns and removes the first element from the queue.- Returns:
- first element in the queue
-
popTail
Returns and removes the last element from the queue.- Returns:
- last element in the queue
-
head
Value of the first element in the queue -
tail
Value of the last element in the queue -
get
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
-
grow
Adds a new element to the end of the list and returns it. If the inner array isn't large enough then it will grow.- Returns:
- instance at the tail
-
growW
Adds a new element to the end of the list and returns it. If the inner array isn't large enough then the oldest element will be written over.- Returns:
- instance at the tail
-
add
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
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
-
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 <A> A innerArray()Description copied from class:CircularArrayBaseReference to the inner array- Specified by:
innerArrayin classCircularArrayBase
-
createInstance
-