% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/60-interval_index-constructors.R
\name{as_interval_index}
\alias{as_interval_index}
\title{Build an Interval Index from \code{x}, \code{start}, and \code{end}}
\usage{
as_interval_index(x, start, end, default_query_bounds = "[)")
}
\arguments{
\item{x}{Elements to add.}

\item{start}{Start endpoints with the same length as \code{x}.}

\item{end}{End endpoints with the same length as \code{x}.}

\item{default_query_bounds}{Boundary convention used as the default for
query operations on this index: one of \code{"[)"}, \code{"[]"}, \code{"()"}, \code{"(]"}.
Per-query \verb{peek_*} / \verb{pop_*} calls may override via their own \code{bounds}
argument.}
}
\value{
An \code{interval_index}.
}
\description{
Constructs an \code{interval_index} by pairing each element of \code{x} with
corresponding \code{start} and \code{end} endpoints.
}
\details{
Output is ordered by interval \code{start}.

Names on \code{x} are preserved as element names.
}
\examples{
ix <- as_interval_index(c("a", "b", "c"), start = c(1, 2, 2), end = c(3, 2, 4))
ix
as.list(peek_all_point(ix, 2))

# Endpoints can be other comparable types
ix_date <- as_interval_index(
  c("phase1", "phase2"),
  start = as.Date(c("2024-01-01", "2024-01-10")),
  end = as.Date(c("2024-01-05", "2024-01-15"))
)
ix_date
}
