peek_top-set-.rstack: Assign to/modify the top of an rstack

Description Usage Arguments Details Value See Also Examples

Description

Allows modification access to the top of a stack.

Usage

1
2
## S3 replacement method for class 'rstack'
peek_top(s, ...) <- value

Arguments

s

rstack to modify the first element of.

...

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

value

value to assign to the top data element.

Details

Runs in O(1) worst case time. Throws an error if the rstack is empty. Modifies the element in place (i.e., is not side-effect-free).

Value

modified rstack.

See Also

peek_top for accessing the top data element.

Examples

1
2
3
4
5
6
7
8
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)

rstackdeque documentation built on May 19, 2017, 3:07 p.m.

Search within the rstackdeque package
Search all R packages, documentation and source code