Class SparseArray

java.lang.Object
com.portal.pcm.AssocArray
com.portal.pcm.SparseArray
All Implemented Interfaces:
Externalizable, Serializable

public class SparseArray extends AssocArray implements Externalizable
The SparseArray class is used to simulate the Portal `Array' in an FList. It is an array that doesn't require all elements to be filled.
See Also:
  • Constructor Details

    • SparseArray

      public SparseArray()
      Constructs an instance of SparseArray. The array is initially empty.
  • Method Details

    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Specified by:
      writeExternal in interface Externalizable
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException
      ClassNotFoundException
    • getSize

      public int getSize()
      Returns the number of element pairs in the array.
      Returns:
      The number of elements in the array.
    • elementAt

      public FList elementAt(int index)
      Returns the element, if any, associated with an index.
      Parameters:
      index - Where to find the element.
      Returns:
      An FList instance, if present, NULL if not.
      See Also:
    • elementAt

      public FList elementAt(Integer index)
      Returns the element, if any, associated with an index.
      Parameters:
      index - Where to find the element.
      Returns:
      An FList instance, if present, NULL if not.
      See Also:
    • getAnyElement

      public FList getAnyElement()
      Returns an element (usually called when it is known that there is only one).
      Returns:
      An FList instance, if present, NULL if not.
    • add

      public void add(int index, FList newElement)
      Adds a new element to the array.
      Parameters:
      index - Where to add the new element.
      newElement - The new element to add.
      See Also:
    • add

      public void add(FList newElement)
      Adds a new element to the end of array.
      Parameters:
      newElement - The new element to add.
      See Also:
    • remove

      public void remove(int index)
      Remove an element from the array.
      Parameters:
      index - Where to remove the element.
    • getValueEnumerator

      public Enumeration<FList> getValueEnumerator()
      Returns an enumeration of the values in the array.
      Returns:
      An enumeration of the values in the array.
    • getKeyEnumerator

      public Enumeration<Integer> getKeyEnumerator()
      Returns an enumeration of the index values in the array.
      Returns:
      An enumeration of the index values in the array.
    • getValues

      public List<FList> getValues()
      Returns a read-only list of the values in the sparsearray
      Returns:
      a read-only list of the values in the sparsearray
    • getKeys

      public List<Integer> getKeys()
      Returns a read-only list of the index values in the sparsearray
      Returns:
      a read-only list of the index values in the sparsearray
    • getPairs

      public AssocArray.PairEnumeration getPairs()
      Description copied from class: AssocArray
      Returns an enumeration of pairs.

      This method provides an enumeration over pairs of keys and values.

      Overrides:
      getPairs in class AssocArray
      Returns:
      An instance of AssocArray.PairEnumeration that enumerates the pairs.
    • dump

      public void dump()
      Dumps the SparseArray.