Package org.apache.xml.utils
Class NodeVector
java.lang.Object
org.apache.xml.utils.NodeVector
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
NodeSetDTM
public class NodeVector extends Object implements Serializable, Cloneable
A very simple table that stores a list of Nodes.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected intm_firstFreeNumber of nodes in this NodeVector. -
Constructor Summary
Constructors Constructor Description NodeVector()Default constructor.NodeVector(int blocksize)Construct a NodeVector, using the given block size. -
Method Summary
Modifier and Type Method Description voidaddElement(int value)Append a Node onto the vector.voidappendNodes(NodeVector nodes)Append the nodes to the list.Objectclone()Get a cloned LocPathIterator.booleancontains(int s)Tell if the table contains the given node.intelementAt(int i)Get the nth element.intindexOf(int elem)Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.intindexOf(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.voidinsertElementAt(int value, int at)Inserts the specified node in this vector at the specified index.voidinsertInOrder(int value)Insert a node in order in the list.intpeepOrNull()Return the node at the top of the stack without popping the stack.intpeepTail()Return the node at the tail of the vector without popping Special purpose method for TransformerImpl, pushElemTemplateElement.intpeepTailSub1()Return the node one position from the tail without popping.intpop()Pop a node from the tail of the vector and return the result.intpopAndTop()Pop a node from the tail of the vector and return the top of the stack after the pop.voidpopPair()Pop a pair of nodes from the tail of the stack.voidpopQuick()Pop a node from the tail of the vector.voidpush(int value)Append a Node onto the vector.voidpushPair(int v1, int v2)Push a pair of nodes into the stack.voidremoveAllElements()Inserts the specified node in this vector at the specified index.voidRemoveAllNoClear()Set the length to zero, but don't clear the array.booleanremoveElement(int s)Removes the first occurrence of the argument from this vector.voidremoveElementAt(int i)Deletes the component at the specified index.voidsetElementAt(int node, int index)Sets the component at the specified index of this vector to be the specified object.voidsetTail(int n)Set the tail of the stack to the given node.voidsetTailSub1(int n)Set the given node one position from the tail.intsize()Get the length of the list.voidsort()Sort an array using a quicksort algorithm.voidsort(int[] a, int lo0, int hi0)Sort an array using a quicksort algorithm.
-
Field Details
-
m_firstFree
protected int m_firstFreeNumber of nodes in this NodeVector.
-
-
Constructor Details
-
NodeVector
public NodeVector()Default constructor. -
NodeVector
public NodeVector(int blocksize)Construct a NodeVector, using the given block size.- Parameters:
blocksize- Size of blocks to allocate
-
-
Method Details
-
clone
Get a cloned LocPathIterator.- Overrides:
clonein classObject- Returns:
- A clone of this
- Throws:
CloneNotSupportedException
-
size
public int size()Get the length of the list.- Returns:
- Number of nodes in this NodeVector
-
addElement
public void addElement(int value)Append a Node onto the vector.- Parameters:
value- Node to add to the vector
-
push
public final void push(int value)Append a Node onto the vector.- Parameters:
value- Node to add to the vector
-
pop
public final int pop()Pop a node from the tail of the vector and return the result.- Returns:
- the node at the tail of the vector
-
popAndTop
public final int popAndTop()Pop a node from the tail of the vector and return the top of the stack after the pop.- Returns:
- The top of the stack after it's been popped
-
popQuick
public final void popQuick()Pop a node from the tail of the vector. -
peepOrNull
public final int peepOrNull()Return the node at the top of the stack without popping the stack. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.- Returns:
- Node at the top of the stack or null if stack is empty.
-
pushPair
public final void pushPair(int v1, int v2)Push a pair of nodes into the stack. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.- Parameters:
v1- First node to add to vectorv2- Second node to add to vector
-
popPair
public final void popPair()Pop a pair of nodes from the tail of the stack. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical. -
setTail
public final void setTail(int n)Set the tail of the stack to the given node. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.- Parameters:
n- Node to set at the tail of vector
-
setTailSub1
public final void setTailSub1(int n)Set the given node one position from the tail. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.- Parameters:
n- Node to set
-
peepTail
public final int peepTail()Return the node at the tail of the vector without popping Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.- Returns:
- Node at the tail of the vector
-
peepTailSub1
public final int peepTailSub1()Return the node one position from the tail without popping. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.- Returns:
- Node one away from the tail
-
insertInOrder
public void insertInOrder(int value)Insert a node in order in the list.- Parameters:
value- Node to insert
-
insertElementAt
public 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- Node to insertat- Position where to insert
-
appendNodes
Append the nodes to the list.- Parameters:
nodes- NodeVector to append to this list
-
removeAllElements
public 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. -
RemoveAllNoClear
public void RemoveAllNoClear()Set the length to zero, but don't clear the array. -
removeElement
public 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- Node to remove from the list- Returns:
- True if the node was successfully removed
-
removeElementAt
public 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- Index of node to remove
-
setElementAt
public void setElementAt(int node, 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:
node- Node to setindex- Index of where to set the node
-
elementAt
public int elementAt(int i)Get the nth element.- Parameters:
i- Index of node to get- Returns:
- Node at specified index
-
contains
public boolean contains(int s)Tell if the table contains the given node.- Parameters:
s- Node to look for- Returns:
- True if the given node was found.
-
indexOf
public 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- Node to look forindex- Index of where to start the search- 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
public 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- Node to look for- 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.
-
sort
Sort an array using a quicksort algorithm.- Parameters:
a- The array to be sorted.lo0- The low index.hi0- The high index.- Throws:
Exception
-
sort
Sort an array using a quicksort algorithm.- Throws:
Exception
-