asd_library.stack
Class Stack

java.lang.Object
  |
  +--asd_library.stack.Stack
All Implemented Interfaces:
java.lang.Cloneable, Stack_adt

public class Stack
extends java.lang.Object
implements Stack_adt, java.lang.Cloneable

Implementation of the abstract data type stack


Constructor Summary
Stack()
           
 
Method Summary
 java.lang.Object clone()
          Returns a shallow copy of this Stack.
 boolean equals(Stack s)
          Compares the specified object with this stack for equality.
 boolean isEmpty()
          Verifies if the stack is empty.
 java.util.ListIterator listIterator()
          Returns a list-iterator of the elements in this queue (in proper sequence)
 java.lang.Object pop()
          Retrieves an item and deletes it from the stack.
 void push(java.lang.Object el)
          Stores an item on the stack.
 java.lang.Object top()
          Retrieves the item from the stack head but doesn't remove it.
 java.lang.String toString()
          Returns a string representation of the stack.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Method Detail

isEmpty

public boolean isEmpty()
Verifies if the stack is empty.

Specified by:
isEmpty in interface Stack_adt
Returns:
true if the stack is empty, false otherwise.

top

public java.lang.Object top()
Retrieves the item from the stack head but doesn't remove it.

Specified by:
top in interface Stack_adt
Returns:
the object on the top of the stack.

pop

public java.lang.Object pop()
Retrieves an item and deletes it from the stack.

Specified by:
pop in interface Stack_adt
Returns:
the object deleted from the stack.

push

public void push(java.lang.Object el)
Stores an item on the stack.

Specified by:
push in interface Stack_adt
Parameters:
el - the object to store.

toString

public java.lang.String toString()
Returns a string representation of the stack. The string representation consists of a list of the collection's elements in the reverse order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).

Overrides:
toString in class java.lang.Object
Returns:
a String that represents the queue.

clone

public java.lang.Object clone()
Returns a shallow copy of this Stack. (The elements themselves are not cloned.)

Overrides:
clone in class java.lang.Object
Returns:
a shallow copy of this Stack instance.

equals

public boolean equals(Stack s)
Compares the specified object with this stack for equality. Returns true if and only if the specified object is also a stack, both stacks have the same size, and all corresponding pairs of elements in the two stacks are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two stacks are defined to be equal if they contain the same elements in the same order.

Returns:
true if the specified object is equal to this stack.

listIterator

public java.util.ListIterator listIterator()
Returns a list-iterator of the elements in this queue (in proper sequence)

Returns:
a ListIterator of the elements in this queue.