Package org.ddogleg.struct
Class BigDogArray<T>
java.lang.Object
org.ddogleg.struct.BigDogArrayBase<T[]>
org.ddogleg.struct.BigDogArray<T>
Implementation of
BigDogArrayBase
for any Object[].-
Nested Class Summary
Nested classes/interfaces inherited from class org.ddogleg.struct.BigDogArrayBase
BigDogArrayBase.AssignNewArrayElements<Array>, BigDogArrayBase.FunctionEachRange<Array>, BigDogArrayBase.NewArray<Array>
-
Field Summary
Fields inherited from class org.ddogleg.struct.BigDogArrayBase
blocks, blockSize, DEFAULT_BLOCK_SIZE, generatorArray, growth, initializeArray, size
-
Constructor Summary
ConstructorDescriptionBigDogArray
(int initialAllocation, int blockSize, BigDogGrowth growth, Factory<T> factory, DProcess<T> reset) BigDogArray
(Factory<T> factory) BigDogArray
(Factory<T> factory, DProcess<T> reset) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
arrayLength
(T[] ts) void
Fills the elements in the specified range with the specified value.void
Simulates a for-each loop.void
forIdx
(int idx0, int idx1, DProcessIdx<T> op) Simulates a for-each loop.get
(int index) Returns the value in the array at the specified indexgetTail
(int index) Returns the value in the array at the specified index, counting from the end of the array.grow()
Adds a new element to the tail and returns it.void
removeSwap
(int index) Removes an element in O(1) time by swapping the specified index with the last index and resizing to size -1.void
reserve
(int desiredSize) Modify reserve so that it doesn't discard the already allocated objectsvoid
resize
(int desiredSize) Override resize so that it calls the reset functionvoid
Resizes the array and fills all new elements with the specified valueMethods inherited from class org.ddogleg.struct.BigDogArrayBase
allocate, append, blockArrayLength, getDesiredBlocks, getTotalAllocation, isIndexOutOfBounds, isValidStructure, processByBlock, removeTail, reset, setArray, setInitialBlockSize
-
Constructor Details
-
BigDogArray
public BigDogArray(int initialAllocation, int blockSize, BigDogGrowth growth, Factory<T> factory, DProcess<T> reset) -
BigDogArray
-
BigDogArray
-
-
Method Details
-
arrayLength
- Specified by:
arrayLength
in classBigDogArrayBase<T[]>
-
reserve
public void reserve(int desiredSize) Modify reserve so that it doesn't discard the already allocated objects- Overrides:
reserve
in classBigDogArrayBase<T[]>
-
grow
Adds a new element to the tail and returns it. -
removeSwap
public void removeSwap(int index) Removes an element in O(1) time by swapping the specified index with the last index and resizing to size -1.- Specified by:
removeSwap
in classBigDogArrayBase<T[]>
-
resize
public void resize(int desiredSize) Override resize so that it calls the reset function- Overrides:
resize
in classBigDogArrayBase<T[]>
- Parameters:
desiredSize
- (Input) New array size
-
resize
Resizes the array and fills all new elements with the specified value- Parameters:
desiredSize
- New array sizeconfigure
- Operator that the "new" element is passed in to.
-
fill
Fills the elements in the specified range with the specified value.- Parameters:
idx0
- (Input) First index, inclusive.idx1
- (Input) last index, exclusive.configure
- Operator that the "new" element is passed in to.
-
get
Returns the value in the array at the specified index- Parameters:
index
- (Input) Index in the array- Returns:
- value at index
-
getTail
Returns the value in the array at the specified index, counting from the end of the array.- Parameters:
index
- (Input) Index relative to the end counting in reverse order. 0 = get(size-1)
-
forEach
Simulates a for-each loop. Passes in element values to 'op' from the specified range.- Parameters:
idx0
- (Input) First index, inclusive.idx1
- (Input) Last index, exclusive.op
- The operator which processes the values
-
forIdx
Simulates a for-each loop. Passes in array indexes and element values to 'op' from the specified range.- Parameters:
idx0
- (Input) First index, inclusive.idx1
- (Input) Last index, exclusive.op
- The operator which processes the values
-