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
Modifier and TypeClassDescriptionstatic interface
Minimal interface for accessing an underlying array structure. -
Method Summary
Modifier and TypeMethodDescriptionReturn a newArray
object with the given values appended.Return a newArray
with the givenvalues
appended.void
checkIndex
(int index) Check the given arrayindex
void
checkIndex
(int from, int until) Check the givenfrom
anduntil
indices.static void
checkIndex
(int from, int until, int size) Check the givenfrom
anduntil
indices.copy()
Return a copy of this array.void
get
(int index) Get the array value at the givenindex
.boolean
isSealed()
Return the seal state of the array.int
length()
Return the array length.static <T> Array<T>
of
(Array.Store<T> store) Create a newArray
from the given object store.static <T> Array<T>
ofLength
(int length) Create a newArray
with the given length.Return a newArray
with the givenvalues
prepended.seal()
Return a new sealed array instance.void
Set thevalue
at the givenindex
.slice
(int from) Return a new array slice starting with thefrom
index.slice
(int from, int until) Return a new array slice starting with thefrom
index anduntil
index.void
sort
(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, wait
Methods 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 thevalue
at 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:
true
is the array is sealed,false
otherwise
-
sort
Sort the store.- Parameters:
from
- the start index where to start sorting (inclusively)until
- the end index where to stop sorting (exclusively)comparator
- theComparator
used to compare sequence elements. Anull
value indicates that the elements' Comparable natural ordering should be used
-
append
Return a newArray
object with the given values appended.- Parameters:
array
- the values to append- Returns:
- a new
Array
object with the elements ofthis
array and the givenarray
appended. - Throws:
NullPointerException
- if the givenarray
isnull
- Since:
- 3.4
-
append
Return a newArray
with the givenvalues
appended.- Parameters:
values
- the values to append- Returns:
- a new
Array
with the elements ofthis
array and the givenvalues
appended. - Throws:
NullPointerException
- if the givenvalues
iterable isnull
- Since:
- 3.4
-
prepend
Return a newArray
with the givenvalues
prepended.- Parameters:
values
- the values to prepend- Returns:
- a new
Array
with the elements ofthis
array and the givenvalues
appended. - Throws:
NullPointerException
- if the givenvalues
iterable 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 thefrom
index.- 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 thefrom
index anduntil
index.- 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 givenfrom
anduntil
indices.- 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 givenfrom
anduntil
indices.- 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 newArray
from 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 newArray
with the given length. The array is created with the defaultObjectStore
object.- Type Parameters:
T
- the array type- Parameters:
length
- the array length- Returns:
- a new array with the given
length
-