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

public Class ObjectStack

extends ObjectVector
Class Inheritance
Imports
java.util.EmptyStackException

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.

Field Summary

Inherited from com.sun.org.apache.xml.internal.utils.ObjectVector:
m_blocksizem_firstFreem_mapm_mapSize

Constructor Summary

AccessConstructor and Description
public
ObjectStack()

Default constructor.

public
ObjectStack(int
Size of block to allocate
blocksize
)

Construct a ObjectVector, using the given block size.

public
ObjectStack(ObjectStack
ObjectStack to copy
v
)

Copy constructor for ObjectStack

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

clone of current ObjectStack
clone
()

Overrides com.sun.org.apache.xml.internal.utils.ObjectVector.clone.

Returns clone of current ObjectStack

public boolean

Returns:

true if this stack is empty; false otherwise.
empty
()

Tests if this stack is empty.

public Object

Returns:

the object at the top of this stack.
peek
()

Looks at the object at the top of this stack without removing it from the stack.

public Object

Returns:

the object at n items down.
peek
(int
The number of items down, indexed from zero.
n
)

Looks at the object at the position the stack counting down n items.

public Object

Returns:

The object at the top of this stack.
pop
()

Removes the object at the top of this stack and returns that object as the value of this function.

public Object

Returns:

the item argument.
push
(Object
the int to be pushed onto this stack.
i
)

Pushes an item onto the top of this stack.

public void
quickPop(int n)

Quickly pops a number of items from the stack.

public int

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.
search
(Object
the desired object.
o
)

Returns where an object is on this stack.

public void
setTop(Object
object to set at the top
val
)

Sets an object at a the top of the statck

Inherited from com.sun.org.apache.xml.internal.utils.ObjectVector:
addElementaddElementsaddElementscontainselementAtindexOfindexOfinsertElementAtlastIndexOfremoveAllElementsremoveElementremoveElementAtsetElementAtsetSizesetToSizesize

Constructor Detail

ObjectStackback to summary
public ObjectStack()

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

ObjectStackback to summary
public ObjectStack(int blocksize)

Construct a ObjectVector, using the given block size.

Parameters
blocksize:int

Size of block to allocate

ObjectStackback to summary
public ObjectStack(ObjectStack v)

Copy constructor for ObjectStack

Parameters
v:ObjectStack

ObjectStack to copy

Method Detail

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides com.sun.org.apache.xml.internal.utils.ObjectVector.clone.

Returns clone of current ObjectStack

Returns:Object

clone of current ObjectStack

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.

emptyback to summary
public boolean empty()

Tests if this stack is empty.

Returns:boolean

true if this stack is empty; false otherwise.

Since
JDK1.0
peekback to summary
public Object peek()

Looks at the object at the top of this stack without removing it from the stack.

Returns:Object

the object at the top of this stack.

Exceptions
EmptyStackException:
if this stack is empty.
peekback to summary
public Object peek(int n)

Looks at the object at the position the stack counting down n items.

Parameters
n:int

The number of items down, indexed from zero.

Returns:Object

the object at n items down.

Exceptions
EmptyStackException:
if this stack is empty.
popback to summary
public Object pop()

Removes the object at the top of this stack and returns that object as the value of this function.

Returns:Object

The object at the top of this stack.

pushback to summary
public Object push(Object i)

Pushes an item onto the top of this stack.

Parameters
i:Object

the int to be pushed onto this stack.

Returns:Object

the item argument.

quickPopback to summary
public void quickPop(int n)

Quickly pops a number of items from the stack.

searchback to summary
public int search(Object o)

Returns where an object is on this stack.

Parameters
o:Object

the desired object.

Returns:int

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
setTopback to summary
public void setTop(Object val)

Sets an object at a the top of the statck

Parameters
val:Object

object to set at the top

Exceptions
EmptyStackException:
if this stack is empty.