stack {rstack} | R Documentation |
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.
Examples
S <- stack$new()
S$push(1L)
S$peek()
S$pop()
S$size()
S$push(NULL)
S$push(iris)
colnames(S$peek())
[Package rstack version 1.0.1 Index]