rpqueue {rstackdeque} | R Documentation |
Create a new empty rpqueue
Description
Creates a new, empty, rpqueue ready for use.
Usage
rpqueue()
Details
An rpqueue provides "First In, First Out" (FIFO) access; envisaged
as a queue, elements may be inserted at the back and removed from the front. Unlike
rdeque
, access is gauranteed O(1)
worst case even when used
persistently, though in most situations rdeques will be faster in practice
(see the documentation for rdeque
for details).
Other handy functions
include as.list
and as.data.frame
(the latter of which requires that
all elements can be appended to become rows of a data frame in a reasonable manner).
Value
a new rpqueue.
References
Okasaki, Chris. Purely Functional Data Structures. Cambridge University Press, 1999.
See Also
rstack
for a fast LIFO-only structure.
Examples
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
print(q)
q2 <- without_front(q)
print(q2)
print(q)
b <- peek_front(q)
print(b)
[Package rstackdeque version 1.1.1 Index]