head.rdeque {rstackdeque} | R Documentation |
Return the first n elements of an rdeque as an rdeque
Description
Returns the first n elements of a deque as a deque, or all of the elements if its length is less than n.
Usage
## S3 method for class 'rdeque'
head(x, n = 6L, ...)
Arguments
x |
rdeque to get the head 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
a new rdeque.
Examples
d <- rdeque()
d <- insert_back(d, "a")
d <- insert_back(d, "b")
d <- insert_back(d, "c")
dt <- head(d, n = 2)
print(dt)
[Package rstackdeque version 1.1.1 Index]