Learn R Programming

rstackdeque (version 1.1.1)

insert_back.rpqueue: 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

"insert_back"(x, e, ...)

Arguments

x
rpqueue to insert onto.
e
element to insert.
...
additional arguments to be passed to or from methods (ignored).

Value

modified version of the rpqueue.

Details

Runs in $O(1)$ time worst-case. Does not modify the original.

References

Okasaki, Chris. Purely Functional Data Structures. Cambridge University Press, 1999.

Examples

Run this code
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
print(q)

q2 <- insert_back(q, "c")
print(q2)
print(q)

Run the code above in your browser using DataLab