rpqueue: Create a new empty rpqueue

Description Usage Details Value References See Also Examples

View source: R/rpqueue.R

Description

Creates a new, empty, rpqueue ready for use.

Usage

1

Details

An rpqueue provides "First In, First Out" (FIFO) access; envisaged as a queue, elements may be inserted at the back and removed from the front. Unlike rdeque, access is gauranteed O(1) worst case even when used persistently, though in most situations rdeques will be faster in practice (see the documentation for rdeque for details).

Other handy functions include as.list and as.data.frame (the latter of which requires that all elements can be appended to become rows of a data frame in a reasonable manner).

Value

a new rpqueue.

References

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

See Also

rstack for a fast LIFO-only structure.

Examples

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

q2 <- without_front(q)
print(q2)
print(q)

b <- peek_front(q)
print(b)

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