Class IntArrayList

java.lang.Object
com.knuddels.jtokkit.api.IntArrayList

public class IntArrayList extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty list with an initial capacity of ten.
    IntArrayList(int initialCapacity)
    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.
    Returns a List<Integer> containing all the elements in this list in proper sequence (from first to last element).
    void
    Removes all the elements from this list.
    void
    ensureCapacity(int minCapacity)
    Increases the capacity of this IntArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
    boolean
     
    int
    get(int index)
    Returns the element at the specified position in this list.
    int
     
    boolean
    Returns true if this list contains no elements.
    int
    set(int index, int element)
    Replaces the element at the specified position in this list with the specified element.
    int
    Returns the number of elements in this list.
    int[]
    Returns an array containing all the elements in this list in proper sequence (from first to last element).
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IntArrayList

      public IntArrayList()
      Constructs an empty list with an initial capacity of ten.
    • IntArrayList

      public IntArrayList(int initialCapacity)
      Constructs an empty list with the specified initial capacity.
      Parameters:
      initialCapacity - the initial capacity of the list
      Throws:
      IllegalArgumentException - if the specified initial capacity is negative
  • Method Details

    • clear

      public void clear()
      Removes all the elements from this list. The list will be empty after this call returns.
    • 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
    • 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 &lt; 0 || index &gt;= size())
    • set

      public int set(int index, int element)
      Replaces the element at the specified position in this list with the specified element.
      Parameters:
      index - index of the element to replace
      element - element to be stored at the specified position
      Returns:
      the element previously at the specified position
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index &lt; 0 || index &gt;= size())
    • ensureCapacity

      public void ensureCapacity(int minCapacity)
      Increases the capacity of this IntArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
      Parameters:
      minCapacity - the desired minimum capacity
    • size

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

      public boolean isEmpty()
      Returns true if this list contains no elements.
      Returns:
      true if this list contains no elements
    • toArray

      public int[] toArray()
      Returns an array containing all the elements in this list in proper sequence (from first to last element).

      The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.

      Returns:
      an array containing all the elements in this list in proper sequence
    • boxed

      public List<Integer> boxed()
      Returns a List<Integer> containing all the elements in this list in proper sequence (from first to last element).

      The returned list will be "safe" in that no reference to it are maintained by this list. (In other words, this method must allocate a new list). The caller is thus free to modify the returned list.

      Returns:
      a List<Integer> containing all the elements in this list in proper sequence
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object