Skip to content

Stack

class Stack<Type> < Object

Last in, first-out (LIFO) stack. Beyond its typical uses, because Stack is a recursive data structure, it provides particularly good sharing under Birch's lazy deep clone mechanism.

Caution

See note under List for possible segfault issues on the destruction of large stacks.

Member Functions

Name Description
size Number of elements.
empty Is this empty?
clear Clear all elements.
top Get the top element.
push Push an element onto the top.
pop Pop an element from the top.

Member Function Details

clear

function clear()

Clear all elements.

empty

function empty() -> Boolean

Is this empty?

pop

function pop()

Pop an element from the top.

push

function push(x:Type)

Push an element onto the top.

  • x: the element.

size

function size() -> Integer

Number of elements.

top

function top() -> Type

Get the top element.