Stack: Stack and StackList classes and methods

View source: R/stack.R

Stack and StackListR Documentation

Stack and StackList classes and methods

Description

push - Append an element.

pop - Remove and return the last element.

clear - Remove all elements.

shift - Remove and return the first element.

first_element - Return the first element. We can't use first because it's taken by the dplyr package and is not an S3 method.

last_element - Return the last element. We can't use last because it's taken by the dplyr package and is not an S3 method.

size - Return the number of elements.

as.Stack - Creates a new Stack from (typically, vector) s.

as.StackList - Creates a new StackList from (typically, list) s.

Stack() - Creates and keeps a stack of items of the same type, implemented as an R vector. The type is determined by the first push operation.

StackList() - Creates and keeps a list of items of the same type, implemented as an R list. The type is determined by the first push operation.

Usage

push(x, value)

pop(x)

clear(x)

shift(x)

first_element(x)

last_element(x)

size(x)

as.Stack(s)

as.StackList(s)

Stack()

StackList()

Arguments

x

A Stack or StackList object.

value

Value to append.

s

A structure to be converted to a Stack or StackList.


tictoc documentation built on April 23, 2023, 9:20 a.m.