Learn R Programming

cppcontainers (version 1.0.4)

top: Access top element

Description

Access the top element in a container without removing it.

Usage

top(x)

Value

Returns the top element.

Arguments

x

A CppStack or CppPriorityQueue object.

See Also

emplace, pop, push.

Examples

Run this code
s <- cpp_stack(1:4)
s
# Top element: 4

top(s)
# [1] 4

s
# Top element: 4

Run the code above in your browser using DataLab