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

public Class IntVector

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

A very simple table that stores a list of int. 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. See also SuballocatedIntVector.

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 int[]
m_map

Array of ints

protected int
m_mapSize

Size of array

Constructor Summary

AccessConstructor and Description
public
IntVector()

Default constructor.

public
IntVector(int
Size of block to allocate
blocksize
)

Construct a IntVector, using the given block size.

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

Construct a IntVector, using the given block size.

public
IntVector(IntVector
Existing IntVector to copy
v
)

Copy constructor for IntVector

Method Summary

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

Append a int onto the vector.

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

Append several int values onto the vector.

public final void
addElements(int
Int to add to the list
numberOfElements
)

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

public Object

Returns:

clone of current IntVector
clone
()

Overrides java.lang.Object.clone.

Returns clone of current IntVector

public final boolean

Returns:

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

Tell if the table contains the given node.

public final int

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
(int
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
(int
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(int
Int to insert
value
,
int
Index of where to insert
at
)

Inserts the specified node 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
(int
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()

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

public final boolean

Returns:

True if the int was removed, false if it was not found
removeElement
(int
Int 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 and int
i
)

Deletes the component at the specified index.

public final void
setElementAt(int
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 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 int[] m_map

Array of ints

m_mapSizeback to summary
protected int m_mapSize

Size of array

Constructor Detail

IntVectorback to summary
public IntVector()

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

IntVectorback to summary
public IntVector(int blocksize)

Construct a IntVector, using the given block size.

Parameters
blocksize:int

Size of block to allocate

IntVectorback to summary
public IntVector(int blocksize, int increaseSize)

Construct a IntVector, using the given block size.

Parameters
blocksize:int

Size of block to allocate

IntVectorback to summary
public IntVector(IntVector v)

Copy constructor for IntVector

Parameters
v:IntVector

Existing IntVector to copy

Method Detail

addElementback to summary
public final void addElement(int value)

Append a int onto the vector.

Parameters
value:int

Int to add to the list

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

Append several int values onto the vector.

Parameters
value:int

Int 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

Int to add to the list

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Returns clone of current IntVector

Returns:Object

clone of current IntVector

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(int s)

Tell if the table contains the given node.

Parameters
s:int

object to look for

Returns:boolean

true if the object is in the list

elementAtback to summary
public final int elementAt(int i)

Get the nth element.

Parameters
i:int

index of object to get

Returns:int

object at given index

indexOfback to summary
public final int indexOf(int 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:int

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(int 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:int

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(int value, int at)

Inserts the specified node 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:int

Int to insert

at:int

Index of where to insert

lastIndexOfback to summary
public final int lastIndexOf(int 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:int

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()

Inserts the specified node 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.

removeElementback to summary
public final boolean removeElement(int 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:int

Int to remove from array

Returns:boolean

True if the int 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 and int

setElementAtback to summary
public final void setElementAt(int 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:int

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

sizeback to summary
public final int size()

Get the length of the list.

Returns:int

length of the list