% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/50-ordered_sequence-ops.R
\name{elements_between}
\alias{elements_between}
\title{Return Elements in a Key Range}
\usage{
elements_between(x, from_key, to_key, include_from = TRUE, include_to = TRUE)
}
\arguments{
\item{x}{An \code{ordered_sequence}.}

\item{from_key}{Lower bound key.}

\item{to_key}{Upper bound key.}

\item{include_from}{Include lower bound when \code{TRUE}.}

\item{include_to}{Include upper bound when \code{TRUE}.}
}
\value{
An \code{ordered_sequence} of matched elements, in key order. Use
\code{\link[=as.list]{as.list()}} to convert to a plain list.
}
\description{
Return Elements in a Key Range
}
\details{
Range membership is controlled by \code{include_from} and \code{include_to}:
\itemize{
\item \code{include_from = TRUE} uses \code{key >= from_key}; otherwise \code{key > from_key}.
\item \code{include_to = TRUE} uses \code{key <= to_key}; otherwise \code{key < to_key}.
}

If no elements fall in the range, returns an empty \code{ordered_sequence}.
}
\examples{
x <- ordered_sequence("a", "b", "c", "d", keys = c(1, 2, 2, 3))
elements_between(x, 2, 3)
as.list(elements_between(x, 2, 3))
elements_between(x, 2, 2, include_to = FALSE)
}
