peek_front.rpqueue: Return the data element at the front of an rpqueue

Description Usage Arguments Details Value See Also Examples

View source: R/peek_front.rpqueue.R

Description

Simply returns the data element sitting at the front of the rpqueue, leaving the queue alone.

Usage

1
2
## S3 method for class 'rpqueue'
peek_front(x, ...)

Arguments

x

rpqueue to peek at.

...

additional arguments to be passed to or from methods (ignored).

Details

Runs in O(1) worst-case time.

Value

data element existing at the front of the queue.

See Also

without_front for removing the front element.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
e <- peek_front(q)
print(e)
print(q)

## Assigning to the front data element with peek_front:
q <- rpqueue()
q <- insert_back(q, data.frame(a = 1, b = 1))
q <- insert_back(q, data.frame(a = 1, b = 1))

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

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

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