upper_bound: Find First Element with Key '>' Query

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

upper_boundR Documentation

Find First Element with Key > Query

Description

Find First Element with Key > Query

Usage

upper_bound(x, key)

Arguments

x

An ordered_sequence.

key

Query key.

Details

upper_bound() finds the first element with key ⁠> key⁠. This skips exact key matches, which is useful for exclusive range endpoints and for finding the position immediately after a duplicate-key run.

Value

A list with fields:

  • found: logical flag.

  • index: one-based position of the first match, or NULL.

  • value: matched element, or NULL.

  • key: matched key, or NULL.

See Also

lower_bound()

Examples

x <- ordered_sequence("a", "b", "c", keys = c(1, 2, 2))
upper_bound(x, 2)
upper_bound(x, 10)

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