stack - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Operations : Stacks : stack

stack

Stack Data Structure

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

stack[new]()

stack[new](x1, ..., xn)

stack[push](x, s)

stack[pop](s)

stack[empty](s)

stack[top](s)

stack[depth](s)

Parameters

s

-

stack

x, x[i]

-

values to be inserted into the stack

Description

• 

The call stack[new]() returns an empty stack. The call stack[new](x1, ..., xn) returns a stack with the values x1, ..., xn on the stack with x1 on the top of the stack.

• 

The call stack[push](x, s) puts x on the top of the stack s while stack[pop](s) returns (and removes) the top element from the stack.

• 

The call stack[empty](s) returns true if the stack s is empty, and false if it is not empty.

• 

Additionally, stack[top](s) returns the top element of the stack (but does not remove it) and stack[depth](s) returns the number of elements in the stack.

• 

An object-oriented stack implementation is available via the Stack constructor.

Examples

sstack[new]greg,tony,bruno,michael:

stack[push]stefan,s

stefan

(1)

stack[depth]s

5

(2)

stack[top]s

stefan

(3)

whilenotstack[empty]sdostack[pop]send do

greg

(4)

See Also

priqueue

queue

Stack

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam