An R6 class representing a stack of objects of any type.
Andrew Sims andrew.sims@newcastle.ac.uk
new()
Create a stack.
Stack$new()
A new Stack
object.
push()
Push an item onto the stack.
Stack$push(x)
x
The item to push onto the top of the stack. It should be of the same class as items previously pushed on to the stack. It is not checked.
An updated Stack
object
pop()
Pop an item from the stack. Stack underflow and raises error.
Stack$pop()
The item previously at the top of the stack.
size()
Gets the number of items on the stack.
Stack$size()
Number of items.
as_list()
Inspect items in the stack.
Stack$as_list()
A list of items.
clone()
The objects of this class are cloneable with this method.
Stack$clone(deep = FALSE)
deep
Whether to make a deep clone.
Conventional implementation of a stack. Used extensively in graph algorithms and offered as a separate class for ease of programming and to ensure that implementations of stacks are optimized. By intention, there is only minimal checking of method arguments. This is to maximize performance and because the class is mainly intended for use internally to rdecision.