APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.utils

public Class ObjectVector

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
com.sun.org.apache.xml.internal.utils.ObjectStack

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

Modifier and TypeField and Description
protected int
m_blocksize

Size of blocks to allocate

protected int
m_firstFree

Number of ints in array

protected Object[]
m_map

Array of objects

protected int
m_mapSize

Size of array

Constructor Summary

AccessConstructor and Description
public
ObjectVector()

Default constructor.

public
ObjectVector(int
Size of block to allocate
blocksize
)

Construct a IntVector, using the given block size.

public
ObjectVector(int
Size of block to allocate
blocksize
,
int increaseSize)

Construct a IntVector, using the given block size.

public
ObjectVector(ObjectVector
Existing ObjectVector to copy
v
)

Copy constructor for ObjectVector

Method Summary

Modifier and TypeMethod and Description
public final void
addElement(Object
Object to add to the list
value
)

Append an object onto the vector.

public final void
addElements(Object
Object to add to the list
value
,
int numberOfElements)

Append several Object values onto the vector.

public final void
addElements(int
number of slots to append
numberOfElements
)

Append several slots onto the vector, but do not set the values.

public Object

Returns:

clone of current ObjectVector
clone
()

Overrides java.lang.Object.clone.

Returns clone of current ObjectVector

public final boolean

Returns:

true if the object is in the list
contains
(Object
object to look for
s
)

Tell if the table contains the given Object.

public final Object

Returns:

object at given index
elementAt
(int
index of object to get
i
)

Get the nth element.

public final int

Returns:

the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.
indexOf
(Object
object to look for
elem
,
int
Index of where to begin search
index
)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

public final int

Returns:

the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.
indexOf
(Object
object to look for
elem
)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

public final void
insertElementAt(Object
Object to insert
value
,
int
Index of where to insert
at
)

Inserts the specified object in this vector at the specified index.

public final int

Returns:

the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.
lastIndexOf
(Object
Object to look for
elem
)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

public final void
removeAllElements()

Remove all elements objects from the list.

public final boolean

Returns:

True if the object was removed, false if it was not found
removeElement
(Object
Object to remove from array
s
)

Removes the first occurrence of the argument from this vector.

public final void
removeElementAt(int
index of where to remove an object
i
)

Deletes the component at the specified index.

public final void
setElementAt(Object
object to set
value
,
int
Index of where to set the object
index
)

Sets the component at the specified index of this vector to be the specified object.

public final void

Returns:

length of the list
setSize
(int sz)

Get the length of the list.

public final void
setToSize(int size)

public final int

Returns:

length of the list
size
()

Get the length of the list.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_blocksizeback to summary
protected int m_blocksize

Size of blocks to allocate

m_firstFreeback to summary
protected int m_firstFree

Number of ints in array

m_mapback to summary
protected Object[] m_map

Array of objects

m_mapSizeback to summary
protected int m_mapSize

Size of array

Constructor Detail

ObjectVectorback to summary
public ObjectVector()

Default constructor. Note that the default block size is very small, for small lists.

ObjectVectorback to summary
public ObjectVector(int blocksize)

Construct a IntVector, using the given block size.

Parameters
blocksize:int

Size of block to allocate

ObjectVectorback to summary
public ObjectVector(int blocksize, int increaseSize)

Construct a IntVector, using the given block size.

Parameters
blocksize:int

Size of block to allocate

ObjectVectorback to summary
public ObjectVector(ObjectVector v)

Copy constructor for ObjectVector

Parameters
v:ObjectVector

Existing ObjectVector to copy

Method Detail

addElementback to summary
public final void addElement(Object value)

Append an object onto the vector.

Parameters
value:Object

Object to add to the list

addElementsback to summary
public final void addElements(Object value, int numberOfElements)

Append several Object values onto the vector.

Parameters
value:Object

Object to add to the list

addElementsback to summary
public final void addElements(int numberOfElements)

Append several slots onto the vector, but do not set the values.

Parameters
numberOfElements:int

number of slots to append

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Returns clone of current ObjectVector

Returns:Object

clone of current ObjectVector

Exceptions
CloneNotSupportedException:

Doc from java.lang.Object.clone.

if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

containsback to summary
public final boolean contains(Object s)

Tell if the table contains the given Object.

Parameters
s:Object

object to look for

Returns:boolean

true if the object is in the list

elementAtback to summary
public final Object elementAt(int i)

Get the nth element.

Parameters
i:int

index of object to get

Returns:Object

object at given index

indexOfback to summary
public final int indexOf(Object elem, int index)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

Parameters
elem:Object

object to look for

index:int

Index of where to begin search

Returns:int

the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.

indexOfback to summary
public final int indexOf(Object elem)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

Parameters
elem:Object

object to look for

Returns:int

the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.

insertElementAtback to summary
public final void insertElementAt(Object value, int at)

Inserts the specified object in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.

Parameters
value:Object

Object to insert

at:int

Index of where to insert

lastIndexOfback to summary
public final int lastIndexOf(Object elem)

Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.

Parameters
elem:Object

Object to look for

Returns:int

the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.

removeAllElementsback to summary
public final void removeAllElements()

Remove all elements objects from the list.

removeElementback to summary
public final boolean removeElement(Object s)

Removes the first occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.

Parameters
s:Object

Object to remove from array

Returns:boolean

True if the object was removed, false if it was not found

removeElementAtback to summary
public final void removeElementAt(int i)

Deletes the component at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously.

Parameters
i:int

index of where to remove an object

setElementAtback to summary
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

object to set

index:int

Index of where to set the object

setSizeback to summary
public final void setSize(int sz)

Get the length of the list.

Returns:void

length of the list

setToSizeback to summary
public final void setToSize(int size)
sizeback to summary
public final int size()

Get the length of the list.

Returns:int

length of the list