Package ints

Class SynchedIntList


  • public class SynchedIntList
    extends java.lang.Object

    Class SynchedIntList represents a list of integers. Class SynchedIntList supports a clear() method, but it does not support a remove() method.

    Instances of class SynchedIntList are thread-safe.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_INIT_CAPACITY
      The default initial capacity of an SynchedIntList, which is 16.
    • Constructor Summary

      Constructors 
      Constructor Description
      SynchedIntList()
      Constructs an SynchedIntList object with the default initial capacity.
      SynchedIntList​(int initCapacity)
      Constructs an SynchedIntList object with the specified initial capacity.
      SynchedIntList​(int[] ia)
      Constructs an SynchedIntList by cloning the specified array.
      SynchedIntList​(SynchedIntList intList)
      Constructs an SynchedIntList by copying the specified SynchedIntList.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int value)
      Adds the specified integer to the end of this list.
      void clear()
      Removes all elements from this list.
      int get​(int index)
      Returns the element at the specified position in this list.
      int set​(int index, int value)
      Replaces the element at the specified position in this list with the specified element.
      int size()
      Returns the number of elements in this list.
      int[] toArray()
      Returns an integer array containing the sequence of elements in this list.
      java.lang.String toString()
      Returns java.util.Arrays.toString(this.toArray())
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_INIT_CAPACITY

        public static final int DEFAULT_INIT_CAPACITY
        The default initial capacity of an SynchedIntList, which is 16.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SynchedIntList

        public SynchedIntList()
        Constructs an SynchedIntList object with the default initial capacity.
        See Also:
        DEFAULT_INIT_CAPACITY
      • SynchedIntList

        public SynchedIntList​(int initCapacity)
        Constructs an SynchedIntList object with the specified initial capacity.
        Parameters:
        initCapacity - the initial capacity of this list
        Throws:
        java.lang.IllegalArgumentException - if initCapacity < 0
      • SynchedIntList

        public SynchedIntList​(int[] ia)
        Constructs an SynchedIntList by cloning the specified array.
        Parameters:
        ia - a list of integer values
        Throws:
        java.lang.NullPointerException - if ia == null
      • SynchedIntList

        public SynchedIntList​(SynchedIntList intList)
        Constructs an SynchedIntList by copying the specified SynchedIntList.
        Parameters:
        intList - a list of integer values
        Throws:
        java.lang.NullPointerException - if intList == null
    • Method Detail

      • add

        public void add​(int value)
        Adds the specified integer to the end of this list.
        Parameters:
        value - the integer to be added to the end of this list
      • get

        public int get​(int index)
        Returns the element at the specified position in this list.
        Parameters:
        index - the index of the element to be returned
        Returns:
        the element at the specified position in this list
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= this.size()
      • set

        public int set​(int index,
                       int value)
        Replaces the element at the specified position in this list with the specified element.
        Parameters:
        index - the index of the element to be replaced
        value - the value to be stored at the specified position in this list
        Returns:
        the previous value at the specified position in this list
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= this.size()
      • size

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

        public int[] toArray()
        Returns an integer array containing the sequence of elements in this list.
        Returns:
        an integer array containing the sequence of elements in this list
      • clear

        public void clear()
        Removes all elements from this list.
      • toString

        public java.lang.String toString()
        Returns java.util.Arrays.toString(this.toArray())
        Overrides:
        toString in class java.lang.Object
        Returns:
        java.util.Arrays.toString(this.toArray())