com.jn.langx.util.collection.stack.Stack Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of langx-java Show documentation
Show all versions of langx-java Show documentation
Java lang extensions for java6+, a supplement to , replacement of a Guava, commons-lang.
Core utilities, Collection utilities, IO utilities, Cache, Configuration library ...
package com.jn.langx.util.collection.stack;
import java.util.Collection;
import java.util.EmptyStackException;
public interface Stack extends Collection {
/**
* Pushes an item onto the top of this stack. This has exactly
* the same effect as:
*
* addElement(item)
*
* @param item the item to be pushed onto this stack.
* @return the item
argument.
* @see java.util.Vector#addElement
*/
public E push(E item);
/**
* Removes the object at the top of this stack and returns that
* object as the value of this function.
*
* @return The object at the top of this stack (the last item
* of the Vector object).
* @throws EmptyStackException if this stack is empty.
*/
public E pop() ;
/**
* Looks at the object at the top of this stack without removing it
* from the stack.
*
* @return the object at the top of this stack (the last item
* of the Vector object).
* @throws EmptyStackException if this stack is empty.
*/
public E peek() ;
/**
* 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.
*
* @param o the desired object.
* @return 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.
*/
public int search(Object o);
}