Stack | R Documentation |
This is a stack data structure, operations you can do with it are:
push
pop
peek
Constructor for Stack
Push an item in the stack
Peek an item from the stack
Return the item on top of the stack. Raises an error if the stack is empty
Pops an item from the stack
returns and removes the item on top of the stack. If the stack is empty, it raises an error.
TRUE
is stack is empty
Returns the length of the stack
Internal method for object rappresentatio on REPL
new()
Stack$new(...)
...
items to be pushed in the stack
Stack$new("first")
push()
Stack$push(item)
item
object to be pushed
peek()
Stack$peek()
element on top of the stack
pop()
Stack$pop()
element on top of the stack
empty()
Stack$empty()
TRUE
if empty, FALSE
otherwise
length()
Stack$length()
the number of elements in the stack
show()
Stack$show(sep = "\n")
sep
separator used on the output
clone()
The objects of this class are cloneable with this method.
Stack$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run: s <- Stack() s$push(1) s$peek() s$pop() ## End(Not run) ## ------------------------------------------------ ## Method `Stack$new` ## ------------------------------------------------ Stack$new("first")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.