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

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)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.