Class DynamicIntArray
java.lang.Object
ai.timefold.solver.core.impl.util.DynamicIntArray
A class representing an int array that is dynamically allocated based on the first set index.
The array is only created when the first element is set and is reallocated as needed
when lower indices are accessed.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDynamicIntArray(int maxLength) DynamicIntArray(int maxLength, DynamicIntArray.ClearingStrategy clearingStrategy) DynamicIntArray(DynamicIntArray.ClearingStrategy clearingStrategy) -
Method Summary
-
Constructor Details
-
DynamicIntArray
public DynamicIntArray() -
DynamicIntArray
-
DynamicIntArray
public DynamicIntArray(int maxLength) -
DynamicIntArray
-
-
Method Details
-
set
public void set(int index, int value) Sets the value at the specified index. If this is the first element, the array is created. If the index is lower than the current firstIndex or higher than the current lastIndex, the array is reallocated with a growth strategy to reduce frequent reallocations.- Parameters:
index- the index at which to set the valuevalue- the value to set
-
get
public int get(int index) Gets the value at the specified index.- Parameters:
index- the index from which to get the value- Returns:
- the value at the index
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
clear
public void clear()Clears the array by setting all values to 0. The array structure is preserved, only the values are reset.
-