pop_max: Pop Maximum-Priority Element

View source: R/40-priority_queue-queue-ops.R

pop_maxR Documentation

Pop Maximum-Priority Element

Description

Removes one maximum-priority element and returns it with the remaining queue.

Usage

pop_max(x)

Arguments

x

A priority_queue.

Details

Ties are stable: when multiple elements share maximum priority, the earliest element in queue order is removed.

Value

A list with fields:

  • value: removed element, or NULL when x is empty.

  • priority: removed priority, or NULL when x is empty.

  • remaining: queue after removal.

Examples

x <- priority_queue("a", "b", "c", priorities = c(2, 3, 3))
out <- pop_max(x)
out$value
out$priority
out$remaining
pop_max(priority_queue())

Immutables documentation built on April 29, 2026, 1:06 a.m.