insert_back.rdeque {rstackdeque}R Documentation

Insert an element into the back of an rdeque

Description

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

Usage

## S3 method for class 'rdeque'
insert_back(x, e, ...)

Arguments

x

rdeque 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 rdeque.

References

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

Examples

d <- rdeque()
d <- insert_back(d, "a")
d <- insert_back(d, "b")
print(d)

d2 <- insert_back(d, "c")
print(d2)
print(d)

[Package rstackdeque version 1.1.1 Index]