Package org.apache.xml.utils
Class IntStack
- java.lang.Object
-
- org.apache.xml.utils.IntVector
-
- org.apache.xml.utils.IntStack
-
- All Implemented Interfaces:
java.lang.Cloneable
public class IntStack extends IntVector
Implement a stack of simple integers. %OPT% This is currently based on IntVector, which permits fast acess but pays a heavy recopying penalty if/when its size is increased. If we expect deep stacks, we should consider a version based on ChunkedIntVector.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Returns clone of current IntStackbooleanempty()Tests if this stack is empty.intpeek()Looks at the object at the top of this stack without removing it from the stack.intpeek(int n)Looks at the object at the position the stack counting down n items.intpop()Removes the object at the top of this stack and returns that object as the value of this function.intpush(int i)Pushes an item onto the top of this stack.voidquickPop(int n)Quickly pops a number of items from the stack.intsearch(int o)Returns where an object is on this stack.voidsetTop(int val)Sets an object at a the top of the statck-
Methods inherited from class org.apache.xml.utils.IntVector
addElement, addElements, addElements, contains, elementAt, indexOf, indexOf, insertElementAt, lastIndexOf, removeAllElements, removeElement, removeElementAt, setElementAt, setSize, size
-
-
-
-
Constructor Detail
-
IntStack
public IntStack()
Default constructor. Note that the default block size is very small, for small lists.
-
IntStack
public IntStack(int blocksize)
Construct a IntVector, using the given block size.- Parameters:
blocksize- Size of block to allocate
-
IntStack
public IntStack(IntStack v)
Copy constructor for IntStack- Parameters:
v- IntStack to copy
-
-
Method Detail
-
push
public int push(int i)
Pushes an item onto the top of this stack.- Parameters:
i- the int to be pushed onto this stack.- Returns:
- the
itemargument.
-
pop
public final int pop()
Removes the object at the top of this stack and returns that object as the value of this function.- Returns:
- The object at the top of this stack.
-
quickPop
public final void quickPop(int n)
Quickly pops a number of items from the stack.
-
peek
public final int peek()
Looks at the object at the top of this stack without removing it from the stack.- Returns:
- the object at the top of this stack.
- Throws:
java.util.EmptyStackException- if this stack is empty.
-
peek
public int peek(int n)
Looks at the object at the position the stack counting down n items.- Parameters:
n- The number of items down, indexed from zero.- Returns:
- the object at n items down.
- Throws:
java.util.EmptyStackException- if this stack is empty.
-
setTop
public void setTop(int val)
Sets an object at a the top of the statck- Parameters:
val- object to set at the top- Throws:
java.util.EmptyStackException- if this stack is empty.
-
empty
public boolean empty()
Tests if this stack is empty.- Returns:
trueif this stack is empty;falseotherwise.- Since:
- JDK1.0
-
search
public int search(int o)
Returns where an object is on this stack.- Parameters:
o- the desired object.- Returns:
- the distance from the top of the stack where the object is]
located; the return value
-1indicates that the object is not on the stack. - Since:
- JDK1.0
-
-