length.rpqueue: Return the number of elements in an rpqueue

Description Usage Arguments Details Value See Also Examples

View source: R/length.rpqueue.R

Description

Returns the number of elements in an rpqueue.

Usage

1
2
## S3 method for class 'rpqueue'
length(x)

Arguments

x

rpqueue to get the length of.

Details

Runs in O(1) time, as this information is stored seperately and updated on every insert/remove.

Value

a vector of length 1 with the number of elements.

See Also

empty for checking whether an rpqueue is empty.

Examples

1
2
3
4
5
q <- rpqueue()
q <- insert_back(q, "a")
print(length(q))         # 1
q <- insert_back(q, "b")
print(length(q))         # 2

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