insert_front.rdeque: Insert an element into the front of an rdeque

Description Usage Arguments Details Value References See Also Examples

View source: R/insert_front.rdeque.R

Description

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

Usage

1
2
## S3 method for class 'rdeque'
insert_front(d, e, ...)

Arguments

d

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

Value

modified version of the rdeque.

References

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

See Also

without_front for removing the front element.

Examples

1
2
3
4
5
6
7
8
d <- rdeque()
d <- insert_front(d, "a")
d <- insert_front(d, "b")
print(d)

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

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