insert_back.rpqueue: Insert an element into the back of an rpqueue

Description Usage Arguments Details Value References Examples

View source: R/insert_back.rpqueue.R

Description

Returns a version of the queue with the new element in the back position.

Usage

1
2
## 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

1
2
3
4
5
6
7
8
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
print(q)

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

rstackdeque documentation built on May 2, 2019, 4:15 a.m.