% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/20-api-generics.R
\name{insert}
\alias{insert}
\title{Insert an Element}
\usage{
insert(x, ...)
}
\arguments{
\item{x}{Object to insert into.}

\item{...}{Method-specific arguments.}
}
\value{
Updated object of the same class as \code{x}.
}
\description{
Inserts an element into a structure-specific position according to class
semantics.
}
\details{
\code{insert()} is an S3 generic. Required arguments in \code{...} depend on \code{x}:
\itemize{
\item \code{priority_queue}: \code{element}, \code{priority} (optional \code{name})
\item \code{ordered_sequence}: \code{element}, \code{key} (optional \code{name})
\item \code{interval_index}: \code{element}, \code{start}, \code{end} (optional \code{name})
}

This operation is persistent: \code{x} is not modified.
}
\examples{
q <- priority_queue("a", "b", priorities = c(2, 1))
insert(q, "c", priority = 3)

o <- ordered_sequence("a", "c", keys = c(1, 3))
insert(o, "b", key = 2)

iv <- interval_index("A", "B", start = c(1, 5), end = c(3, 8))
insert(iv, "C", start = 2, end = 6)
}
\seealso{
\code{\link[=priority_queue]{priority_queue()}}, \code{\link[=ordered_sequence]{ordered_sequence()}}, \code{\link[=interval_index]{interval_index()}},
\code{\link[=insert_at]{insert_at()}}
}
