head.rpqueue: Return the head (front) of an rpqueue

Description Usage Arguments Details Value See Also Examples

View source: R/head.rpqueue.R

Description

Returns the first n elements of an rpqueue as an rpqueue, or all of the elements if length(x) < n.

Usage

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

Arguments

x

rpqueue 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 rpqueue.

See Also

rpqueue.

Examples

1
2
3
4
5
6
7
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
q <- insert_back(q, "c")

qt <- head(q, n = 2)
print(qt)

rstackdeque documentation built on May 29, 2017, 5:34 p.m.

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