Class IntIntIndexedList

  • All Implemented Interfaces:
    java.io.Serializable

    public class IntIntIndexedList
    extends java.lang.Object
    implements java.io.Serializable
    Manages an array of lists of ints. It provides methods for adding, deleting, and retrieving int values for specific lists.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      IntIntIndexedList​(int numLists)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int listID, int value)
      Add a value to the front of the list indexed by listID.
      void append​(int listID, int value)
      Add a value to the back of the list indexed by listID.
      void clear()
      Removes all values from all lists.
      boolean contains​(int listID, int value)
      Returns true if the value exists in the specified list.
      int[] get​(int listID)
      Get list of values stored in the specified list.
      int getCount​(int listID)
      Get the number of values in the specified list.
      int getNumLists()
      Returns the number of lists.
      void growNumLists​(int numLists)
      Increase the number of lists.
      boolean remove​(int listID, int value)
      Remove the value from the list indexed by listID.
      void removeAll​(int listID)
      Remove all values from a specified list.
      • Methods inherited from class java.lang.Object

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

      • IntIntIndexedList

        public IntIntIndexedList​(int numLists)
        Constructor
        Parameters:
        numLists - initial number of lists.
    • Method Detail

      • add

        public void add​(int listID,
                        int value)
        Add a value to the front of the list indexed by listID.
        Parameters:
        listID - specifies which list the value is to be added.
        value - the value to be added to the list.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • append

        public void append​(int listID,
                           int value)
        Add a value to the back of the list indexed by listID.
        Parameters:
        listID - specifies which list the value is to be appended.
        value - the value to be added to the linked list.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • remove

        public boolean remove​(int listID,
                              int value)
        Remove the value from the list indexed by listID.
        Parameters:
        listID - specifies from which list to remove the value.
        value - the value to remove removed from the specified list.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • removeAll

        public void removeAll​(int listID)
        Remove all values from a specified list.
        Parameters:
        listID - the id of the list to be cleared.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • contains

        public boolean contains​(int listID,
                                int value)
        Returns true if the value exists in the specified list.
        Parameters:
        listID - the id of the list to check for the value.
        value - the value to searched for in the given list.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • getCount

        public int getCount​(int listID)
        Get the number of values in the specified list.
        Parameters:
        listID - the id of the list for which to get the number of values.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • get

        public int[] get​(int listID)
        Get list of values stored in the specified list.
        Parameters:
        listID - the id of the list to get values for.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • getNumLists

        public int getNumLists()
        Returns the number of lists.
      • growNumLists

        public void growNumLists​(int numLists)
        Increase the number of lists.
        Parameters:
        numLists - the new number of lists.
      • clear

        public void clear()
        Removes all values from all lists.