pop_key: Pop First Element for One Key

View source: R/50-ordered_sequence-ops.R

pop_keyR Documentation

Pop First Element for One Key

Description

Removes and returns the first element whose key equals key.

Usage

pop_key(x, key)

Arguments

x

An ordered_sequence.

key

Query key.

Details

For duplicate keys, the first element in stable sequence order is removed.

Value

A list with fields:

  • value: removed element, or NULL on miss.

  • key: removed key, or NULL on miss.

  • remaining: ordered sequence after removal.

Examples

x <- ordered_sequence("a", "b", "c", keys = c(1, 2, 2))
out <- pop_key(x, 2)
out$value
out$remaining
pop_key(x, 10)

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