peek_front.rpqueue {rstackdeque} | R Documentation |
Return the data element at the front of an rpqueue
Description
Simply returns the data element sitting at the front of the rpqueue, leaving the queue alone.
Usage
## 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
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)
[Package rstackdeque version 1.1.1 Index]