head.rpqueue {rstackdeque} | R Documentation |
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
## 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
Examples
q <- rpqueue()
q <- insert_back(q, "a")
q <- insert_back(q, "b")
q <- insert_back(q, "c")
qt <- head(q, n = 2)
print(qt)
[Package rstackdeque version 1.1.1 Index]