peek_back: Return the data element at the back of an rdeque

View source: R/peek_back.R

peek_backR Documentation

Return the data element at the back of an rdeque

Description

Simply returns the data element sitting at the back of the rdeque, leaving the rdeque alone.

Usage

peek_back(d, ...)

Arguments

d

rdeque 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 back of the rdeque.

See Also

without_back for removing the front element.

Examples

d <- rdeque()
d <- insert_front(d, "a")
d <- insert_front(d, "b")
e <- peek_back(d)
print(e)
print(d)

## Assigning to the front data element with peek_front:
d <- rdeque()
d <- insert_front(d, data.frame(a = 1, b = 1))
d <- insert_front(d, data.frame(a = 1, b = 1))

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

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

oneilsh/rstackdeque documentation built on May 17, 2022, 6:29 p.m.