peek_front.rpqueue {rstackdeque} | R Documentation |
Simply returns the data element sitting at the front of the rpqueue, leaving the queue alone.
## S3 method for class 'rpqueue' peek_front(x, ...)
x |
rpqueue to peek at. |
... |
additional arguments to be passed to or from methods (ignored). |
Runs in O(1)
worst-case time.
data element existing at the front of the queue.
without_front
for removing the front element.
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)