Class ObjectVector
java.lang.Object
org.loboevolution.apache.xml.utils.ObjectVector
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final int
Size of blocks to allocateprotected int
Number of ints in arrayprotected Object[]
Array of objectsprotected int
Size of array -
Constructor Summary
ConstructorsConstructorDescriptionObjectVector
(int blocksize, int increaseSize) Construct a IntVector, using the given block size.Copy constructor for ObjectVector -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addElement
(Object value) Append an object onto the vector.clone()
final Object
elementAt
(int i) Get the nth element.final void
setElementAt
(Object value, int index) Sets the component at the specified index of this vector to be the specified object.final void
setToSize
(int size) final int
size()
Get the length of the list.
-
Field Details
-
m_blocksize
protected final int m_blocksizeSize of blocks to allocate -
m_map
Array of objects -
m_firstFree
protected int m_firstFreeNumber of ints in array -
m_mapSize
protected int m_mapSizeSize 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 allocateincreaseSize
- the size to inc
-
ObjectVector
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
Append an object onto the vector.- Parameters:
value
- Object to add to the list
-
setElementAt
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 setindex
- Index of where to set the object
-
elementAt
Get the nth element.- Parameters:
i
- index of object to get- Returns:
- object at given index
-
setToSize
public final void setToSize(int size) -
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-