% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/40-priority_queue-constructors.R
\name{as_priority_queue}
\alias{as_priority_queue}
\title{Build a Priority Queue from \code{x} and \code{priorities}}
\usage{
as_priority_queue(x, priorities)
}
\arguments{
\item{x}{Elements to enqueue.}

\item{priorities}{Priorities with the same length as \code{x}.}
}
\value{
A \code{priority_queue}.
}
\description{
Constructs a queue by pairing each element of \code{x} with the corresponding
value in \code{priorities}.
}
\details{
\code{x} is interpreted element-wise (via list coercion). Names on \code{x} are
preserved as queue element names.

All priorities must be non-missing and mutually comparable.
}
\examples{
x <- as_priority_queue(letters[1:4], priorities = c(3, 1, 2, 1))
x
peek_min(x)
peek_max(x)

# Names are preserved
n <- as_priority_queue(setNames(as.list(1:3), c("a", "b", "c")), priorities = c(2, 1, 3))
n[["b"]]
}
