Class ShortLongIndexedList

  • All Implemented Interfaces:
    java.io.Serializable

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

      Constructors 
      Constructor Description
      ShortLongIndexedList​(short numLists)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(short listID, long value)
      Add a value to the front of the list indexed by listID.
      void append​(short listID, long value)
      Add a value to the back of the list indexed by listID.
      void clear()
      Removes all values from all lists.
      boolean contains​(short listID, long value)
      Returns true if the value exists in the specified list.
      long[] get​(short listID)
      Get values stored in the specified list.
      int getCount​(short listID)
      Get the number of values in the specified list.
      short getNumLists()
      Returns the number of lists.
      void growNumLists​(short numLists)
      Increase the number of lists.
      boolean remove​(short listID, long value)
      Remove the value from the list indexed by listID.
      void removeAll​(short 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

      • ShortLongIndexedList

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

      • add

        public void add​(short listID,
                        long 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​(short listID,
                           long 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​(short listID,
                              long value)
        Remove the value from the list indexed by listID.
        Parameters:
        listID - the id of the list from which to remove the value.
        value - the value to be removed from the specified list.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • removeAll

        public void removeAll​(short 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​(short listID,
                                long value)
        Returns true if the value exists in the specified list.
        Parameters:
        listID - the id of the list to be tested for the given value.
        value - the value to search for in the specified list.
        Throws:
        java.lang.IndexOutOfBoundsException - thrown if the listID is not in the range [0, numLists].
      • getCount

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

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

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

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

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