Class ObjectVector

java.lang.Object
org.loboevolution.apache.xml.utils.ObjectVector
All Implemented Interfaces:
Cloneable

public class ObjectVector extends Object implements Cloneable
A very simple table that stores a list of objects.

This version is based on a "realloc" strategy -- a simle array is used, and when more storage is needed, a larger array is obtained and all existing data is recopied into it. As a result, read/write access to existing nodes is O(1) fast but appending may be O(N**2) slow.

  • Field Details

    • m_blocksize

      protected final int m_blocksize
      Size of blocks to allocate
    • m_map

      protected Object[] m_map
      Array of objects
    • m_firstFree

      protected int m_firstFree
      Number of ints in array
    • m_mapSize

      protected int m_mapSize
      Size of array
  • Constructor Details

    • ObjectVector

      public ObjectVector(int blocksize, int increaseSize)
      Construct a IntVector, using the given block size.
      Parameters:
      blocksize - Size of block to allocate
      increaseSize - the size to inc
    • ObjectVector

      public ObjectVector(ObjectVector v)
      Copy constructor for ObjectVector
      Parameters:
      v - Existing ObjectVector to copy
  • Method Details

    • size

      public final int size()
      Get the length of the list.
      Returns:
      length of the list
    • addElement

      public final void addElement(Object value)
      Append an object onto the vector.
      Parameters:
      value - Object to add to the list
    • setElementAt

      public final void setElementAt(Object value, int index)
      Sets the component at the specified index of this vector to be the specified object. The previous component at that position is discarded.

      The index must be a value greater than or equal to 0 and less than the current size of the vector.

      Parameters:
      value - object to set
      index - Index of where to set the object
    • elementAt

      public final Object elementAt(int i)
      Get the nth element.
      Parameters:
      i - index of object to get
      Returns:
      object at given index
    • setToSize

      public final void setToSize(int size)
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException