tips.collectionTest
Class ReversibleStack

java.lang.Object
  extended bytips.collectionTest.ReversibleStack

public class ReversibleStack
extends java.lang.Object

This class demonstrates the use of the collection classes. This object implements a reversible stack, hence it implements the usual pop() push() methods but will also implement reverse() and sort().


Field Summary
private  int m_nCount
           
private  java.util.List m_TheStack
          Stack implementation is done using a linked list
 
Constructor Summary
ReversibleStack()
          Creates a new instance of ReversibleStack
ReversibleStack(java.lang.Object[] arr)
          Create a mew instance of ReversibleStack initialing with the element of the array
 
Method Summary
static void main(java.lang.String[] args)
          Main Code - used to test the class
 java.lang.Object pop()
          Provides Pop functionality for the stack
 void print()
          Debug method to print the contents of the stack
 boolean push(java.lang.Object o)
          Provides Push functionaliy.
 void reverse()
          Method that reverses the contents of the Stack
 void sort()
          Function to sort the contents of the stack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_TheStack

private java.util.List m_TheStack
Stack implementation is done using a linked list


m_nCount

private int m_nCount
Constructor Detail

ReversibleStack

public ReversibleStack()
Creates a new instance of ReversibleStack


ReversibleStack

public ReversibleStack(java.lang.Object[] arr)
Create a mew instance of ReversibleStack initialing with the element of the array

Method Detail

push

public boolean push(java.lang.Object o)
Provides Push functionaliy.

Parameters:
o - The object to be pushed on to the stack.
Returns:
true if successful

pop

public java.lang.Object pop()
Provides Pop functionality for the stack

Returns:
The object popped from the top of the stack
Throws:
None.

reverse

public void reverse()
Method that reverses the contents of the Stack


sort

public void sort()
Function to sort the contents of the stack


print

public void print()
Debug method to print the contents of the stack


main

public static void main(java.lang.String[] args)
Main Code - used to test the class