java.lang.Object
io.jenetics.ext.internal.util.IntList
Resizable-int array implementation
- Since:
- 4.1
- Version:
- 4.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int element) Appends the specified element to the end of this list.voidadd(int index, int element) Inserts the specified element at the specified position in this list.booleanaddAll(int[] elements) Appends all of the elements in the specified array to the end of this list.booleanaddAll(int index, int[] elements) Inserts all the elements in the specified array into this list, starting at the specified position.voidclear()Removes all of the elements from this list.voidforEach(IntConsumer action) Performs the given action for each element of the list.intget(int index) Returns the element at the specified position in this list.booleanisEmpty()Returntrueif the list is empty.intsize()Returns the number of elements in this list.stream()Returns a sequentialIntStreamwith the specified list as its source.int[]toArray()Return the current elements as int array.voidTrims the capacity of thisArrayListinstance to be the list's current size.
-
Constructor Details
-
IntList
Constructs an empty list with the specified initial capacity.- Parameters:
capacity- the initial capacity of the list- Throws:
IllegalArgumentException- if the specified initial capacity is negative
-
IntList
public IntList()Constructs an empty list with an initial capacity of ten.
-
-
Method Details
-
get
Returns the element at the specified position in this list.- Parameters:
index- index of the element to return- Returns:
- the element at the specified position in this list
- Throws:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index > size())
-
forEach
Performs the given action for each element of the list.- Parameters:
action- the action to be performed for each element- Throws:
NullPointerException- if the specified action isnull
-
stream
Returns a sequentialIntStreamwith the specified list as its source.- Returns:
- a sequential
IntStream
-
add
Appends the specified element to the end of this list.- Parameters:
element- element to be appended to this list
-
add
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).- Parameters:
index- index at which the specified element is to be insertedelement- element to be inserted- Throws:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index > size())
-
addAll
Appends all of the elements in the specified array to the end of this list.- Parameters:
elements- array containing elements to be added to this list- Returns:
trueif this list changed as a result of the call- Throws:
NullPointerException- if the specified array is null
-
addAll
Inserts all the elements in the specified array into this list, starting at the specified position.- Parameters:
index- index at which to insert the first element from the specified collectionelements- collection containing elements to be added to this list- Returns:
trueif this list changed as a result of the call- Throws:
IndexOutOfBoundsException- if the index is out of range(index < 0 || index > size())NullPointerException- if the specified array is null
-
clear
Removes all of the elements from this list. The list will be empty after this call returns. -
trimToSize
Trims the capacity of thisArrayListinstance to be the list's current size. An application can use this operation to minimize the storage of anArrayListinstance. -
size
Returns the number of elements in this list.- Returns:
- the number of elements in this list
-
isEmpty
Returntrueif the list is empty.- Returns:
trueif the list is empty,falseotherwise
-
toArray
Return the current elements as int array.- Returns:
- the current elements as int array
-