stack

0th

Percentile

A stack data type, implemented as an R6 class

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.

Keywords
datasets
Usage
stack
Format

An object of class R6ClassGenerator of length 24.

Aliases
  • stack
Examples
S <- stack$new()
S$push(1L)
S$peek()
S$pop()
S$size()

S$push(NULL)
S$push(iris)
colnames(S$peek())
Documentation reproduced from package rstack, version 1.0.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.