Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.javatools.xml.esax.spi
Class Stack

java.lang.Object
  extended by java.util.AbstractCollection
      extended by oracle.javatools.xml.esax.spi.Stack

All Implemented Interfaces:
java.lang.Iterable, java.util.Collection

public final class Stack
extends java.util.AbstractCollection

Convenient implementation of a Last In First Out (LIFO) stack. This implementation differs from the one in java.util.Stack in two ways. First, like most of the collection APIs, it is unsynchronized for better performance when synchronization is not required. If a synchronized stack is required, you can use the Collections.synchronizedCollection() method to retrieve a synchronized instance. Second, it does not expose its internal implementation via its superclass. Extending AbstractCollection instead of Vector allows objects of this class to be used interchangably with other collection framework classes without exposing its internal implementation.


Constructor Summary
Stack()
          Construct a stack with no additional arguments.
Stack(java.util.Collection c)
          Construct a stack initialized to contain all the items in the specified collection.

 

Method Summary
 boolean add(java.lang.Object o)
           
 void clear()
           
 boolean isEmpty()
          Gets whether there are more elements on the stack.
 java.util.Iterator iterator()
          Gets an iterator for elements on the stack.
 java.lang.Object peek()
          Obtains the top element on the stack without removing it.
 java.lang.Object pop()
          Pops the top element off the stack and returns it.
 boolean push(java.lang.Object o)
          Pushes an element onto the stack.
 void replace(java.lang.Object o)
          Replaces the top of the stack with the specified object.
 java.util.Iterator reverseIterator()
          Gets an iterator for elements on the stack.
 int size()
           

 

Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface java.util.Collection
equals, hashCode

 

Constructor Detail

Stack

public Stack()
Construct a stack with no additional arguments.

Stack

public Stack(java.util.Collection c)
Construct a stack initialized to contain all the items in the specified collection. The items will be pushed on to the stack in their order in the collection.
Parameters:
c - a collection of items to push onto the stack.

Method Detail

isEmpty

public boolean isEmpty()
Gets whether there are more elements on the stack.
Specified by:
isEmpty in interface java.util.Collection
Overrides:
isEmpty in class java.util.AbstractCollection
Returns:
true if there are no more elements on the stack.

push

public boolean push(java.lang.Object o)
Pushes an element onto the stack.
Parameters:
o - an element to push onto the stack
Returns:
true if the stack changed as a result of this operation.

peek

public java.lang.Object peek()
Obtains the top element on the stack without removing it.
Returns:
the top element on the stack.

replace

public void replace(java.lang.Object o)
Replaces the top of the stack with the specified object.
Parameters:
o - the object to replace the top of the stack with.

pop

public java.lang.Object pop()
Pops the top element off the stack and returns it.
Returns:
the old top element

reverseIterator

public java.util.Iterator reverseIterator()
Gets an iterator for elements on the stack. This iterator starts at the bottom of the stack and proceeds to the top.
Returns:
an iterator over stack elements.

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection
Overrides:
add in class java.util.AbstractCollection

clear

public void clear()
Specified by:
clear in interface java.util.Collection
Overrides:
clear in class java.util.AbstractCollection

iterator

public java.util.Iterator iterator()
Gets an iterator for elements on the stack. The iterator starts at the top of the stack and proceeds to the bottom of the stack.
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in class java.util.AbstractCollection
Returns:
an iterator over stack elements.

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in class java.util.AbstractCollection

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


Copyright © 1997, 2012, Oracle. All rights reserved.