sub-.interval_index: Indexing for Interval Indexes

sub-.interval_indexR Documentation

Indexing for Interval Indexes

Description

Read indexing returns interval_index subsets while preserving interval/key order; out-of-order selectors are canonicalized with a warning. Replacement indexing is blocked.

Usage

## S3 method for class 'interval_index'
x[i, ...]

## S3 method for class 'interval_index'
x[[i, ...]]

## S3 replacement method for class 'interval_index'
x[i] <- value

## S3 replacement method for class 'interval_index'
x[[i]] <- value

## S3 method for class 'interval_index'
x$name

## S3 replacement method for class 'interval_index'
x$name <- value

Arguments

x

An interval_index.

i

Index input.

...

Unused.

value

Replacement value (unsupported).

name

Element name (for $ and ⁠$<-⁠).

Details

Read indexing preserves canonical interval order in returned subsets.

  • Integer/character vectors are treated as selectors and canonicalized to interval-order output.

  • Out-of-order selector vectors trigger a warning and are canonicalized.

  • Duplicate selectors are rejected.

  • [[ and $ return payload values.

  • Replacement indexing (⁠[<-⁠, ⁠[[<-⁠, ⁠$<-⁠) is unsupported.

Value

Read methods return interval payload values/subsets; replacement forms always error.

For $: the matched payload element.

No return value; always errors because replacement indexing is unsupported.

Examples

ix <- interval_index(a = "A", b = "B", c = "C", start = c(1, 3, 5), end = c(2, 4, 6))

ix[c(3, 1)]         # warning; result returned in interval order
ix[c("c", "a")]     # warning; result returned in interval order
ix[c(TRUE, FALSE, TRUE)]
ix[["b"]]
ix$b

try(ix[c(2, 2)])
try(ix$b <- "updated")

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