Learn R Programming

tictoc (version 1.0)

Stack: Stack and List 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 - Return the first element.

last - Return the last element.

size - Return the number of elements.

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

as.List - Creates a new List 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.

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

Usage

# S3 method for default
push(x, value)

# S3 method for default pop(x)

# S3 method for default clear(x)

# S3 method for default shift(x)

# S3 method for default first(x)

# S3 method for default last(x)

# S3 method for default size(x)

# S3 method for default as.Stack(s)

# S3 method for default as.List(s)

Stack()

List()

Arguments

x

A Stack or List object.

value

Value to append.

s

A structure to be converted to a Stack or List.