libperun

Class std.cont.Stack

Synopsis

public abstract class Stack< T > extends Container< T >

Represents an abstract stack.

This is a container which allows items to be added with the push() method, and then retrieved using pop() on a first-in-last-out basis.

Fields

Constructors

Methods

public abstract void push(T element);

Push an element onto the top of the stack.

public abstract T pop();

Pop and element from the top of the stack and return it.

public abstract int size();

Return the number of elements on the stack.

protected abstract T get(int index);

Return the element with the specified index (index zero referring to the top of the stack).

public final T opGet(int index);

Return the element with the specified index (index zero referring to the top of the stack).

protected abstract void set(int index,T value);

Set the element with the specified index to the specified value.

public final void opSet(int index,T value);

Set the element with the specified index to the specified value.