insert_back.rpqueue {rstackdeque} | R Documentation |
Insert an element into the back of an rpqueue
Description
Returns a version of the queue with the new element in the back position.
Usage
## S3 method for class 'rpqueue'
insert_back(x, e, ...)
Arguments
x |
rpqueue to insert onto. |
e |
element to insert. |
... |
additional arguments to be passed to or from methods (ignored). |
Details
Runs in O(1)
time worst-case. Does not modify the original.
Value
modified version of the rpqueue.
References
Okasaki, Chris. Purely Functional Data Structures. Cambridge University Press, 1999.
Examples
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
print(q)
q2 <- insert_back(q, "c")
print(q2)
print(q)
[Package rstackdeque version 1.1.1 Index]