Learn R Programming

cppcontainers (version 1.0.4)

pop: Remove top element

Description

Remove top element in a stack or priority queue or the first element in a queue by reference.

Usage

pop(x)

Value

Invisibly returns NULL.

Arguments

x

A CppStack, CppQueue, or CppPriorityQueue object.

Details

In a stack, it is the last inserted element. In a queue, it is the first inserted element. In a descending (ascending) priority queue, it is the largest (smallest) value.

See Also

back, emplace, front, push, top.

Examples

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

pop(s)
s
# Top element: 5

q <- cpp_queue(4:6)
q
# First element: 4

pop(q)
q
# First element: 5

p <- cpp_priority_queue(4:6)
p
# First element: 6

pop(p)
p
# First element: 5

Run the code above in your browser using DataLab