Thursday 5 April 2012

Class - Stack


Stack

Stack is a subclass of vector that implements  a standard last_in,first_out stack.
Stack only defines the default constructor, which creates an empty stack.

 

Method:


boolean empty()
Returns true if the stack is empty, and returns false if the stack contains elements.

Object peek()
Returns the element on the top of the stack, but does not remove it .

Object pop()
Returns the element on the top of the Stack removing it in the process.

Object push(Object element)
Pushes element on to the stack element is also returned

int search(object element)
Searches for element in the stack. If found its offset from the top of the stack is returned. Otherwise,-1 is returned.


Posted By : Ruchita Pnadya

No comments:

Post a Comment