count_between: Count Elements in a Key Range

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

count_betweenR Documentation

Count Elements in a Key Range

Description

Count Elements in a Key Range

Usage

count_between(x, from_key, to_key, include_from = TRUE, include_to = TRUE)

Arguments

x

An ordered_sequence.

from_key

Lower bound key.

to_key

Upper bound key.

include_from

Include lower bound when TRUE.

include_to

Include upper bound when TRUE.

Details

Uses the same range semantics as elements_between() but returns only the count:

  • include_from = TRUE uses key >= from_key; otherwise key > from_key.

  • include_to = TRUE uses key <= to_key; otherwise key < to_key.

Value

Integer count of matches.

Examples

x <- ordered_sequence("a", "b", "c", "d", keys = c(1, 2, 2, 3))
count_between(x, 2, 3)
count_between(x, 2, 2, include_to = FALSE)

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