java.lang.Object
Array<T>
- Type Parameters:
T- the array element type
- All Implemented Interfaces:
BaseMSeq<T>,BaseSeq<T>,Serializable,Iterable<T>,RandomAccess
Array implementation class. This class manages the actual array (store) and
the start index and the length.
- Since:
- 3.4
- Version:
- 6.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceMinimal interface for accessing an underlying array structure. -
Method Summary
Modifier and TypeMethodDescriptionReturn a newArrayobject with the given values appended.Return a newArraywith the givenvaluesappended.voidcheckIndex(int index) Check the given arrayindexvoidcheckIndex(int from, int until) Check the givenfromanduntilindices.static voidcheckIndex(int from, int until, int size) Check the givenfromanduntilindices.copy()Return a copy of this array.voidget(int index) Get the array value at the givenindex.booleanisSealed()Return the seal state of the array.intlength()Return the array length.static <T> Array<T>of(Array.Store<T> store) Create a newArrayfrom the given object store.static <T> Array<T>ofLength(int length) Create a newArraywith the given length.Return a newArraywith the givenvaluesprepended.seal()Return a new sealed array instance.voidSet thevalueat the givenindex.slice(int from) Return a new array slice starting with thefromindex.slice(int from, int until) Return a new array slice starting with thefromindex anduntilindex.voidsort(int from, int until, Comparator<? super T> comparator) Sort the store.store()Return the underlying array store.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jenetics.util.BaseSeq
forEach, isEmpty, iterator, listIterator, nonEmpty, spliterator, stream
-
Method Details
-
get
Get the array value at the givenindex. The array index is not checked. -
length
Return the array length. -
set
Set thevalueat the givenindex. The array index is not checked. -
store
Return the underlying array store.- Returns:
- the underlying array store
-
copyIfSealed
-
seal
Return a new sealed array instance. The underlying store is sealed as well, but not copied.- Returns:
- a new sealed array
-
isSealed
Return the seal state of the array.- Returns:
trueis the array is sealed,falseotherwise
-
sort
Sort the store.- Parameters:
from- the start index where to start sorting (inclusively)until- the end index where to stop sorting (exclusively)comparator- theComparatorused to compare sequence elements. Anullvalue indicates that the elements' Comparable natural ordering should be used
-
append
Return a newArrayobject with the given values appended.- Parameters:
array- the values to append- Returns:
- a new
Arrayobject with the elements ofthisarray and the givenarrayappended. - Throws:
NullPointerException- if the givenarrayisnull- Since:
- 3.4
-
append
Return a newArraywith the givenvaluesappended.- Parameters:
values- the values to append- Returns:
- a new
Arraywith the elements ofthisarray and the givenvaluesappended. - Throws:
NullPointerException- if the givenvaluesiterable isnull- Since:
- 3.4
-
prepend
Return a newArraywith the givenvaluesprepended.- Parameters:
values- the values to prepend- Returns:
- a new
Arraywith the elements ofthisarray and the givenvaluesappended. - Throws:
NullPointerException- if the givenvaluesiterable isnull- Since:
- 3.4
-
copy
Return a copy of this array.- Returns:
- a copy of this array
-
slice
Return a new array slice starting with thefromindex.- Parameters:
from- the start index- Returns:
- a new array slice
- Throws:
ArrayIndexOutOfBoundsException- if the index is out of bounds.
-
slice
Return a new array slice starting with thefromindex anduntilindex.- Parameters:
from- the start indexuntil- the end index- Returns:
- a new array slice
- Throws:
ArrayIndexOutOfBoundsException- if the indexes are out of bounds.
-
checkIndex
Check the given arrayindex- Parameters:
index- the index to check- Throws:
ArrayIndexOutOfBoundsException- if the given index is not in the valid range.
-
checkIndex
Check the givenfromanduntilindices.- Parameters:
from- the from index, inclusively.until- the until index, exclusively.- Throws:
ArrayIndexOutOfBoundsException- if the given index is not in the valid range.
-
checkIndex
Check the givenfromanduntilindices.- Parameters:
from- the from index, inclusively.until- the until index, exclusively.size- the array size- Throws:
ArrayIndexOutOfBoundsException- if the given index is not in the valid range.
-
of
Create a newArrayfrom the given object store.- Type Parameters:
T- the array type- Parameters:
store- the object store- Returns:
- a new array with the given
store
-
ofLength
Create a newArraywith the given length. The array is created with the defaultObjectStoreobject.- Type Parameters:
T- the array type- Parameters:
length- the array length- Returns:
- a new array with the given
length
-