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

Description Usage Arguments Details Value See Also Examples

View source: R/length.rstack.R

Description

Returns the number of elements in an rstack.

Usage

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

Arguments

x

rstack 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, which the number of elements of the stack.

See Also

empty for checking whether an rstack is empty.

Examples

1
2
3
4
5
s <- rstack()
s <- insert_top(s, "a")
print(length(s))         # 1
s <- insert_top(s, "b")
print(length(s))         # 2

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