java::util::Stack Class Reference

Inheritance diagram for java::util::Stack:

Inheritance graph
java::util::ListStackjava::lang::Interfacejava::lang::Object
[legend]
Collaboration diagram for java::util::Stack:

Collaboration graph
java::lang::Interfacejava::lang::Object
[legend]

List of all members.


Detailed Description

The Stack interface represents a last-in-first-out (LIFO) stack of objects.

It accept class List with operations that allow a list to be treated as a stack. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack isEmpty, and a method to search the stack for an item and discover how far it is from the top.

When a stack is first created, it contains no items.

Author:
Jonathan Payne
Version:
1.25, 12/03/01
Since:
JDK1.0

Public Member Functions

virtual jint size () const =0
 The size of this stack.
virtual jboolean isEmpty () const =0
 Tests if this stack is empty.
virtual ObjectRef push (const ObjectRef &item)=0
 Pushes an item onto the top of this stack.
virtual ObjectRef pop ()=0
 Removes the object at the top of this stack and returns that object as the value of this function.
virtual ObjectRef peek () const =0
 Looks at the object at the top of this stack without removing it from the stack.
virtual jint search (const ObjectRef &o) const =0
 Returns the 1-based position where an object is on this stack.
virtual void clear ()=0
 Removes all elements from the stack.

Static Public Member Functions

static Ref< StacksynchronizedStack (const Ref< Stack > &c, const Ref< Sync > &sync=0)
 Returns a synchronized (thread-safe) stack backed by the specified stack.

Member Function Documentation

static Ref<Stack> java::util::Stack::synchronizedStack ( const Ref< Stack > &  c,
const Ref< Sync > &  sync = 0 
) [static]

Returns a synchronized (thread-safe) stack backed by the specified stack.

In order to guarantee serial access, it is critical that all access to the backing stack is accomplished through the returned stack.

Parameters:
c the stack to be "wrapped" in a synchronized stack.
Returns:
a synchronized view of the specified stack.

virtual jint java::util::Stack::size (  )  const [pure virtual]

The size of this stack.

Returns:
the number of objects in this stack.

Implemented in java::util::ListStack.

virtual jboolean java::util::Stack::isEmpty (  )  const [pure virtual]

Tests if this stack is empty.

Returns:
true if and only if this stack contains no items; false otherwise.

Implemented in java::util::ListStack.

virtual ObjectRef java::util::Stack::push ( const ObjectRef item  )  [pure virtual]

Pushes an item onto the top of this stack.

Parameters:
item the item to be pushed onto this stack.
Returns:
the item argument.
See also:
java.util.Vector::addElement

Implemented in java::util::ListStack.

virtual ObjectRef java::util::Stack::pop (  )  [pure virtual]

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 (the last item of the Vector object).
Exceptions:
NoSuchElementException if this stack is empty.

Implemented in java::util::ListStack.

virtual ObjectRef java::util::Stack::peek (  )  const [pure virtual]

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 (the last item of the Vector object).
Exceptions:
NoSuchElementException if this stack is empty.

Implemented in java::util::ListStack.

virtual jint java::util::Stack::search ( const ObjectRef o  )  const [pure virtual]

Returns the 1-based position where an object is on this stack.

If the object o occurs as an item in this stack, this method returns the distance from the top of the stack of the occurrence nearest the top of the stack; the topmost item on the stack is considered to be at distance 1. The equals method is used to compare o to the items in this stack.

Parameters:
o the desired object.
Returns:
the 1-based position from the top of the stack where the object is located; the return value -1 indicates that the object is not on the stack.

Implemented in java::util::ListStack.

virtual void java::util::Stack::clear (  )  [pure virtual]

Removes all elements from the stack.

Implemented in java::util::ListStack.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:52 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3