Stack

types/collections/stack.ql

Function Overview

Function Description
static fun fromList(list) Creates a new stack from a list of elements.
fun push(element) Pushes an element onto the stack.
fun pop() Pops an element from the stack.
fun peek() Peeks at the top element of the stack.
fun isEmpty() Checks if the stack is empty.
fun size() Gets the size of the stack.
fun toList() Converts the stack to a list.

Field Overview

Field Description
any _stack

Functions

static fun fromList(list) link

Creates a new stack from a list of elements.

Params
list ( list )

A list of elements

Returns Stack

A new stack with the given elements

fun push(element) link

Pushes an element onto the stack.

Params
element

The element to push onto the stack

fun pop() link

Pops an element from the stack.

Returns

The element popped from the stack

Errors

If the stack is empty

fun peek() link

Peeks at the top element of the stack.

Returns

The top element of the stack

Errors

If the stack is empty

fun isEmpty() link

Checks if the stack is empty.

Returns boolean

true if the stack is empty, false if otherwise

fun size() link

Gets the size of the stack.

Returns int

The size of the stack

fun toList() link

Converts the stack to a list.

Returns list

A list of all elements in the stack