java.lang.Object
io.jenetics.ext.internal.util.IntList
Resizable-int array implementation
- Since:
- 4.1
- Version:
- 4.3
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int element) Appends the specified element to the end of this list.void
add
(int index, int element) Inserts the specified element at the specified position in this list.boolean
addAll
(int[] elements) Appends all of the elements in the specified array to the end of this list.boolean
addAll
(int index, int[] elements) Inserts all the elements in the specified array into this list, starting at the specified position.void
clear()
Removes all of the elements from this list.void
forEach
(IntConsumer action) Performs the given action for each element of the list.int
get
(int index) Returns the element at the specified position in this list.boolean
isEmpty()
Returntrue
if the list is empty.int
size()
Returns the number of elements in this list.stream()
Returns a sequentialIntStream
with the specified list as its source.int[]
toArray()
Return the current elements as an int array.void
Trims the capacity of thisArrayList
instance 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 sequentialIntStream
with 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:
true
if 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:
true
if 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 thisArrayList
instance to be the list's current size. An application can use this operation to minimize the storage of anArrayList
instance. -
size
Returns the number of elements in this list.- Returns:
- the number of elements in this list
-
isEmpty
Returntrue
if the list is empty.- Returns:
true
if the list is empty,false
otherwise
-
toArray
Return the current elements as an int array.- Returns:
- the current elements as an int array
-