GAP (datastructures) - Chapter 12: Stacks

Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 Bib Ind
[Top of Book] [Contents] [Previous Chapter] [Next Chapter]

[MathJax off]

12 Stacks
12.1 API
12.1-1 Stack
12.1-2 IsStack
12.1-3 Push
12.1-4 Peek
12.1-5 Pop
12.1-6 Size

### 12 Stacks

A stack is a deque where items can be `Push`ed onto the stack, and the top item can be `Pop`ped off the stack.

Stacks are wrapped GAP plain lists.

#### 12.1 API

##### 12.1-1 Stack

`‣ Stack`( ) | ( function )

Returns: stack

Constructor for stacks

##### 12.1-2 IsStack

`‣ IsStack`( arg ) | ( filter )

Returns: `true` or `false`

Category of heaps

##### 12.1-3 Push

`‣ Push`( stack, object ) | ( operation )

Puts object onto stack.

##### 12.1-4 Peek

`‣ Peek`( stack ) | ( operation )

Returns: object or `fail`

Return the object at the top of stack. If stack is empty, returns `fail`

##### 12.1-5 Pop

`‣ Pop`( stack ) | ( operation )

Returns: object or `fail`

Remove the top item from stack and return it. If stack is empty, this function returns fail.

##### 12.1-6 Size

`‣ Size`( arg ) | ( attribute )

Number of elements on stack

[Top of Book] [Contents] [Previous Chapter] [Next Chapter]
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 10 11 12 Bib Ind

generated by GAPDoc2HTML