head.rdeque: Return the first n elements of an rdeque as an rdeque

Description Usage Arguments Details Value Examples

View source: R/head.rdeque.R

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

1
2
## 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

1
2
3
4
5
6
7
d <- rdeque()
d <- insert_back(d, "a")
d <- insert_back(d, "b")
d <- insert_back(d, "c")

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

rstackdeque documentation built on May 2, 2019, 4:15 a.m.