stack: Stack

View source: R/stack.R

stackR Documentation

Stack

Description

stack creates a stack.

Usage

stack(items = NULL)

Arguments

items

a list of items

Details

Following methods are exposed:

.$push(item)
.$pop()
.$peek()
.$clear()
.$size()
.$as_list()
.$print()
  • item: any R object

See Also

queue and deque

Examples

s <- stack()
s$push("first")
s$push("second")
s$pop()  # second
s$pop()  # first

s <- stack(list("foo", "bar"))
s$push("baz")$push("bla")

collections documentation built on Jan. 6, 2023, 1:25 a.m.