Learn R Programming

rstackdeque (version 1.1.1)

head.rdeque: 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

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

Value

a new rdeque.

Details

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

Examples

Run this code
d <- rdeque()
d <- insert_back(d, "a")
d <- insert_back(d, "b")
d <- insert_back(d, "c")

dt <- head(d, n = 2)
print(dt)

Run the code above in your browser using DataLab