Package frc.lib.util

Class IntArrayList

java.lang.Object
frc.lib.util.IntArrayList
All Implemented Interfaces:
Serializable, Cloneable, RandomAccess

public class IntArrayList extends Object implements RandomAccess, Cloneable, Serializable
An optimized int array. Used in lieu of an ArrayList<Integer> to avoid boxing (and the performance implications that come with it).
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int[]
     
    static final int
    During list creation, many reallocations at low capacities may be common, so we jump from 0 to 10 before our normal reallocation scheme.
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new array list with DEFAULT_INITIAL_CAPACITY capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int k)
    Appends k to the end of this list.
    void
    Remove all values.
    int
    get(int index)
    Get long element at index index.
    boolean
    Checks if the list has no elements.
    int
    remove(int index)
    Removes the element at the specified position in this list.
    int
    Returns the number of elements in this list.
    int[]
    Convert to an array.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_INITIAL_CAPACITY

      public static final int DEFAULT_INITIAL_CAPACITY
      During list creation, many reallocations at low capacities may be common, so we jump from 0 to 10 before our normal reallocation scheme.
      See Also:
    • backing

      protected transient int[] backing
    • size

      protected int size
  • Constructor Details

  • Method Details

    • add

      public void add(int k)
      Appends k to the end of this list.
    • get

      public int get(int index)
      Get long element at index index.
    • isEmpty

      public boolean isEmpty()
      Checks if the list has no elements.
    • size

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

      public int remove(int index)
      Removes the element at the specified position in this list.
    • clear

      public void clear()
      Remove all values.
    • toArray

      public int[] toArray()
      Convert to an array. This performs a copy, since the backing array may be larger than the array needed to be returned.