Creates a new, empty, rdeque ready for use.
An rdeque provided both "Last In, First Out" (LIFO) and "First In, First Out" (FIFO) access;
envisaged as queue, elements may be added or removed from the front or the back with
without_back. The front and back
elements may be retrieved with
Internally, rdeques are stored as a pair of rstacks; they provide O(1)-amortized insertion and removal,
so long as they are not used persistently (that is, the variable storing the deque is always replaced
by the modified version, e.g.
s <- without_front(s)). When used persistently (e.g.
s2 <- without_front(s), which results
in two deques being accessible), this cannot be gauranteed. When an O(1) worst-cast, fully
persistent FIFO queue is needed, the rpqueue from this package provides these semantics. However,
there is a constant-time overhead for rpqueues, such that rdeques are often more efficient (and flexible)
in practice, even in when used persistently.
Other useful functions
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).
a new empty rdeque.
Okasaki, Chris. Purely Functional Data Structures. Cambridge University Press, 1999.
rstack for a fast LIFO-only structure.
1 2 3 4 5 6 7 8 9 10 11 12 13
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.