org.apache.xml.utils

Class ObjectStack

public class ObjectStack extends ObjectVector

Implement a stack of simple integers. %OPT% This is currently based on ObjectVector, 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 ChunkedObjectVector.

UNKNOWN: internal

Constructor Summary
ObjectStack()
Default constructor.
ObjectStack(int blocksize)
Construct a ObjectVector, using the given block size.
ObjectStack(ObjectStack v)
Copy constructor for ObjectStack
Method Summary
Objectclone()
Returns clone of current ObjectStack
booleanempty()
Tests if this stack is empty.
Objectpeek()
Looks at the object at the top of this stack without removing it from the stack.
Objectpeek(int n)
Looks at the object at the position the stack counting down n items.
Objectpop()
Removes the object at the top of this stack and returns that object as the value of this function.
Objectpush(Object i)
Pushes an item onto the top of this stack.
voidquickPop(int n)
Quickly pops a number of items from the stack.
intsearch(Object o)
Returns where an object is on this stack.
voidsetTop(Object val)
Sets an object at a the top of the statck

Constructor Detail

ObjectStack

public ObjectStack()
Default constructor. Note that the default block size is very small, for small lists.

ObjectStack

public ObjectStack(int blocksize)
Construct a ObjectVector, using the given block size.

Parameters: blocksize Size of block to allocate

ObjectStack

public ObjectStack(ObjectStack v)
Copy constructor for ObjectStack

Parameters: v ObjectStack to copy

Method Detail

clone

public Object clone()
Returns clone of current ObjectStack

Returns: clone of current ObjectStack

empty

public boolean empty()
Tests if this stack is empty.

Returns: true if this stack is empty; false otherwise.

Since: JDK1.0

peek

public Object 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: EmptyStackException if this stack is empty.

peek

public Object 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: EmptyStackException if this stack is empty.

pop

public Object 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.

push

public Object push(Object i)
Pushes an item onto the top of this stack.

Parameters: i the int to be pushed onto this stack.

Returns: the item argument.

quickPop

public void quickPop(int n)
Quickly pops a number of items from the stack.

search

public int search(Object 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 -1 indicates that the object is not on the stack.

Since: JDK1.0

setTop

public void setTop(Object val)
Sets an object at a the top of the statck

Parameters: val object to set at the top

Throws: EmptyStackException if this stack is empty.

Copyright © 2005 Apache XML Project. All Rights Reserved.