Class IntArrayList


  • public class IntArrayList
    extends Object
    An extendable array of primitive int values.
    Author:
    Martin Davis
    • Constructor Summary

      Constructors 
      Constructor Description
      IntArrayList()
      Constructs an empty list.
      IntArrayList​(int initialCapacity)
      Constructs an empty list with the specified initial capacity
    • Constructor Detail

      • IntArrayList

        public IntArrayList()
        Constructs an empty list.
      • IntArrayList

        public IntArrayList​(int initialCapacity)
        Constructs an empty list with the specified initial capacity
        Parameters:
        initialCapacity - the initial capacity of the list
    • Method Detail

      • size

        public int size()
        Returns the number of values in this list.
        Returns:
        the number of values in the list
      • ensureCapacity

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

        public void add​(int value)
        Adds a value to the end of this list.
        Parameters:
        value - the value to add
      • addAll

        public void addAll​(int[] values)
        Adds all values in an array to the end of this list.
        Parameters:
        values - an array of values
      • toArray

        public int[] toArray()
        Returns a int array containing a copy of the values in this list.
        Returns:
        an array containing the values in this list