stack: Stack

Description Usage Arguments Details Value

Description

Stack is an abstract data type which allows for pushing elements and popping them in reverse (last in-first out) order.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
stack_create()

## S3 method for class 'Stack'
as.list(stack)

stack_empty(stack)

stack_push(stack, obj)

stack_pop(stack)

## S3 method for class 'Stack'
print(stack, ...)

## S3 method for class 'Stack'
format(stack, ...)

## S3 method for class 'Stack'
str(stack, ...)

Arguments

stack

a stack object

obj

an R object

...

other arguments passed to or from other methods

Details

stack_create creates a new stack.

as.list.Stack converts a given stack object to an R list.

stack_empty determines if a given stack is empty or not.

stack_push pushes a given object to the top of the stack.

stack_pop pops an object from the top of the stack.

print.Stack prints the contents of the stack (coerced to a list object) on the console.

format.Stack pretty-prints the contents of the stack (coerced to a list object) on the console.

str.Stack compactly displays the contents of the stack (coerced to a list object) on the console.

Value

stack_create returns a new, empty stack.

as.list.Stack returns an R list object.

stack_empty returns a single logical value.

stack_push does not return anything interesting.

stack_pop returns an object at the top of te stack or throws an error if the stack is empty.

print.Stack returns the stack coerced to a list, invisibly.

format.Stack returns the character representation of the objects in the stack.

str.Stack does not return anything interesting.


Rexamine/DataStructures documentation built on May 9, 2019, 10 a.m.