org.hawk.ds
Class Stack<T>

java.lang.Object
  extended by org.hawk.ds.Stack<T>

public class Stack<T>
extends java.lang.Object

Not to be confused with java's stack... Their's is a implemenation with fundamental mistake.


Constructor Summary
Stack()
           
 
Method Summary
 java.lang.String dump()
          Returns the stack dump
 boolean isEmpty()
          This deontes whether a stack is empty or not.
<T> T
pop()
          This pops out the top object present in the stack.
 boolean push(T obj)
          This pushes object to the stack.
<T> T
top()
          This returns the top object present in the stack.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stack

public Stack()
Method Detail

push

public boolean push(T obj)
This pushes object to the stack.

Parameters:
obj -
Returns:
returns true on successful addition to the stack.

pop

public <T> T pop()
This pops out the top object present in the stack.

Returns:
returns the top object present in the stack.

top

public <T> T top()
This returns the top object present in the stack.

Returns:
returns the top object present in the stack.

dump

public java.lang.String dump()
Returns the stack dump

Returns:
returns the stack dump.

isEmpty

public boolean isEmpty()
This deontes whether a stack is empty or not.

Returns:
true if the stack is empty otherwise false

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object