peek_top.rstack {rstackdeque} | R Documentation |
Simply returns the data element sitting at the top of the rstack, leaving the rstack alone.
## S3 method for class 'rstack'
peek_top(s, ...)
s |
rstack 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 top of the rstack.
without_top
for removing the top element.
s <- rstack()
s <- insert_top(s, "a")
s <- insert_top(s, "b")
e <- peek_top(s)
print(e)
print(s)
## Assigning to the top data element with peek_top:
s <- rstack()
s <- insert_top(s, data.frame(a = 1, b = 1))
s <- insert_top(s, data.frame(a = 1, b = 1))
peek_top(s)$a <- 100
print(s)
peek_top(s) <- data.frame(a = 100, b = 100)