Learn R Programming

rstackdeque (version 1.1.1)

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

Description

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

Usage

"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).

Value

an rpqueue.

Details

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

See Also

rpqueue.

Examples

Run this code
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
q <- insert_back(q, "c")

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

Run the code above in your browser using DataLab