rstack (version 1.0.0)

stack: A stack data type, implemented as an R6 class

Description

Methods:

  • push(elem) Puts an R object on the top of the stack. This operation might trigger the allocation of memory, if the currently allocated memory cannot hold the new element. Still, the amortized time complexity of the stack is constant. The stack may contain arbitrary R objects.

  • pop() Removes and returns the top element of the stack. It throws an error if the stack is empty.

  • peek() Returns the top element of the stack. (Without removing it.) It throws an error if the stack is empty.

  • size() Returns the number of elements in the stack.

  • is_empty() Returns wheather the stack is empty.

Usage

stack

Arguments

Format

An object of class R6ClassGenerator of length 24.

Examples

Run this code
S <- stack$new()
S$push(1L)
S$peek()
S$pop()
S$size()

S$push(NULL)
S$push(iris)
colnames(S$peek())

Run the code above in your browser using DataLab