cpp_queue {cppcontainers} | R Documentation |
Create queue
Description
Create a queue. Queues are first-in, first-out containers.
Usage
cpp_queue(x)
Arguments
x |
An integer, numeric, character, or logical vector. |
Details
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
.
Value
Returns a CppQueue object referencing a queue in C++.
Examples
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
[Package cppcontainers version 1.0.0 Index]