Class IntList

java.lang.Object
io.jenetics.ext.internal.util.IntList

public final class IntList extends Object
Resizable-int array implementation
Since:
4.1
Version:
4.3
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty list with an initial capacity of ten.
    IntList(int capacity)
    Constructs an empty list with the specified initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    Removes all of the elements from this list.
    void
    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
    Return true if the list is empty.
    int
    Returns the number of elements in this list.
    Returns a sequential IntStream with the specified list as its source.
    int[]
    Return the current elements as an int array.
    void
    Trims the capacity of this ArrayList instance to be the list's current size.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IntList

      public IntList(int capacity)
      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

      public int get(int index)
      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

      public void forEach(IntConsumer action)
      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 is null
    • stream

      public IntStream stream()
      Returns a sequential IntStream with the specified list as its source.
      Returns:
      a sequential IntStream
    • add

      public void add(int element)
      Appends the specified element to the end of this list.
      Parameters:
      element - element to be appended to this list
    • add

      public void add(int index, int element)
      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 inserted
      element - element to be inserted
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index > size())
    • addAll

      public boolean addAll(int[] elements)
      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

      public boolean addAll(int index, int[] elements)
      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 collection
      elements - 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

      public void clear()
      Removes all of the elements from this list. The list will be empty after this call returns.
    • trimToSize

      public void trimToSize()
      Trims the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.
    • size

      public int size()
      Returns the number of elements in this list.
      Returns:
      the number of elements in this list
    • isEmpty

      public boolean isEmpty()
      Return true if the list is empty.
      Returns:
      true if the list is empty, false otherwise
    • toArray

      public int[] toArray()
      Return the current elements as an int array.
      Returns:
      the current elements as an int array