GAP (datastructures) - Chapter 11: Stacks

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

[MathJax off]

11 Stacks
11.1 API
11.1-1 Stack
11.1-2 IsStack
11.1-3 Push
11.1-4 Peek
11.1-5 Pop
11.1-6 Size

### 11 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.

#### 11.1 API

##### 11.1-1 Stack

`‣ Stack`( ) | ( function )

Returns: stack

Constructor for stacks

##### 11.1-2 IsStack

`‣ IsStack`( arg ) | ( filter )

Returns: `true` or `false`

Category of heaps

##### 11.1-3 Push

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

Puts object onto stack.

##### 11.1-4 Peek

`‣ Peek`( stack ) | ( operation )

Returns: object or `fail`

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

##### 11.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.

##### 11.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 Bib Ind

generated by GAPDoc2HTML