% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/20-api-generics.R
\name{as_flexseq}
\alias{as_flexseq}
\title{Coerce Objects to \code{flexseq}}
\usage{
as_flexseq(x)
}
\arguments{
\item{x}{Input object.}
}
\value{
A plain \code{flexseq}.
}
\description{
\code{as_flexseq()} is the canonical way to obtain a plain \code{flexseq} for full
sequence-style operations.
}
\details{
For base vectors/lists, this builds a new \code{flexseq} preserving element order
and names.

For specialized immutable subclasses (\code{priority_queue},
\code{ordered_sequence}, \code{interval_index}), this intentionally drops subclass
semantics and returns a plain \code{flexseq}.

This is an S3 generic. Notable method behavior:
\itemize{
\item \code{as_flexseq.flexseq(x)} returns \code{x} unchanged.
\item \code{as_flexseq.priority_queue(x)} returns payload items.
\item \code{as_flexseq.ordered_sequence(x)} returns payload items.
\item \code{as_flexseq.interval_index(x)} returns payload items.
}

For advanced types, custom monoids are dropped and the rebuilt \code{flexseq}
keeps only structural monoids (\code{.size}, \code{.named_count}). For
\code{priority_queue}, a flexseq of full entry records can be obtained by
composing with \code{\link[=as.list]{as.list()}}: \code{as_flexseq(as.list(x))}. For
\code{ordered_sequence} and \code{interval_index}, \code{as.list()} also returns
payload-only lists, so no direct record-preserving cast is provided.
}
\examples{
x <- as_flexseq(1:3)
x

q <- priority_queue("a", "b", priorities = c(2, 1))
as_flexseq(q)

o <- ordered_sequence("a", "b", keys = c(2, 1))
as_flexseq(o)
}
\seealso{
\code{\link[=flexseq]{flexseq()}}, \code{\link[=priority_queue]{priority_queue()}}, \code{\link[=ordered_sequence]{ordered_sequence()}}, \code{\link[=interval_index]{interval_index()}}
}
