head.rstack: Return the head (top) of an rstack

Description Usage Arguments Details Value See Also Examples

View source: R/head.rstack.R

Description

Returns the top n elements of an rstack as an stack, or all of the elements if length(x) < n.

Usage

1
2
## S3 method for class 'rstack'
head(x, n = 6L, ...)

Arguments

x

rstack to get the head/top of.

n

number of elements to get.

...

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

Details

Runs in O(n) time (in the size of the number of elements requested).

Value

an rstack.

See Also

rstack.

Examples

1
2
3
4
5
6
7
8
s <- rstack()
s <- insert_top(s, "a")
s <- insert_top(s, "b")
s <- insert_top(s, "c")

st <- head(s, n = 2)
print(st)
print(s)

rstackdeque documentation built on May 2, 2019, 4:15 a.m.