| cpp_queue | R Documentation |
Create a queue. Queues are first-in, first-out containers.
cpp_queue(x)
x |
An integer, numeric, character, or logical vector. |
The first element added to a queue is the first one to remove.
C++ queue methods implemented in this package are back, emplace, empty, front, pop, push, and size. 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 CppQueue object referencing a queue in C++.
q <- cpp_queue(1:4)
q
# First element: 1
push(q, 9L)
q
# First element: 1
back(q)
# [1] 9
emplace(q, 10L)
back(q)
# [1] 10
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.