peek_front-set: Assign to/modify the front of an rdeque or rpqueue

Description Usage Arguments Details Value Examples

Description

Allows modification access to the front of a deque or queue.

Usage

1
peek_front(x, ...) <- value

Arguments

x

rdeque or rpqueue to modify the front element of.

...

additional arguments to be passed to or from methods.

value

value to assign to the front data element.

Details

Runs in O(1) worst case time. Throws an error if the deque is empty.

Value

modified rdeque or rpqueue.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
d <- rdeque()
d <- insert_front(d, data.frame(a = 1, b = 1))
d <- insert_front(d, data.frame(a = 1, b = 1))

peek_front(d)$a <- 100
print(d)

peek_front(d) <- data.frame(a = 100, b = 100)



q <- rpqueue()
q <- insert_front(d, data.frame(a = 1, b = 1))
q <- insert_front(d, data.frame(a = 1, b = 1))

peek_front(q)$a <- 100
print(q)

peek_front(q) <- data.frame(a = 100, b = 100)

rstackdeque documentation built on May 29, 2017, 5:34 p.m.

Search within the rstackdeque package
Search all R packages, documentation and source code