| cpp_stack | R Documentation |
Create a stack. Stacks are last-in, first-out containers.
cpp_stack(x)
x |
An integer, numeric, character, or logical vector. |
The last element added to a stack is the first one to remove.
C++ stack methods implemented in this package are emplace, empty, pop, push, size, and top. The package also adds the == operator and various helper functions (print, to_r, type).
All object-creating methods in this package begin with cpp_ to avoid clashes with functions from other packages, such as utils::stack and
base::vector.
Returns a CppStack object referencing a stack in C++.
cpp_queue, cpp_priority_queue.
s <- cpp_stack(4:6)
s
# Top element: 6
emplace(s, 3L)
s
# Top element: 3
push(s, 9L)
s
# Top element: 9
pop(s)
s
# Top element: 3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.