head.rpqueue {rstackdeque} | R Documentation |
Returns the first n elements of an rpqueue as an rpqueue, or all of the elements
if length(x) < n
.
## S3 method for class 'rpqueue' head(x, n = 6L, ...)
x |
rpqueue to get the head/top of. |
n |
number of elements to get. |
... |
arguments to be passed to or from other methods (ignored). |
Runs in O(n) time (in the size of the number of elements requested).
an rpqueue
.
q <- rpqueue() q <- insert_back(q, "a") q <- insert_back(q, "b") q <- insert_back(q, "c") qt <- head(q, n = 2) print(qt)