faststack is backed by a list. The backing list will grow or shrink as
the stack changes in size.
faststack(init = 20, missing_default = NULL)
Initial size of the list that backs the stack. This is also used as the minimum size of the list; it will not shrink any smaller.
The value to return when
faststack objects have the following methods:
Push an object onto the stack.
mpush(..., .list = NULL)
Push objects onto the stack.
.list can be a list of objects to add.
pop(missing = missing_default)
Remove and return the top object on the stack. If the stack is empty,
it will return
missing, which defaults to the value of
stack() was created with (typically,
mpop(n, missing = missing_default)
Remove and return the top
n objects on the stack, in a list. The first
element of the list is the top object in the stack. If
n is greater
than the number of objects in the stack, any requested items beyond
those in the stack will be replaced with
peek(missing = missing_default)
Return the top object on the stack, but do not remove it from the stack.
If the stack is empty, this will return
Reset the stack, clearing all items.
Returns the number of items in the stack.
Return a list containing the objects in the stack, where the first element in the list is the object at the bottom of the stack, and the last element in the list is the object at the top of the stack.