% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/40-priority_queue-queue-ops.R
\name{merge.priority_queue}
\alias{merge.priority_queue}
\title{Merge Two Priority Queues}
\usage{
\method{merge}{priority_queue}(x, y, ...)
}
\arguments{
\item{x}{A \code{priority_queue}.}

\item{y}{A \code{priority_queue}.}

\item{...}{Unused.}
}
\value{
A new \code{priority_queue} of size \code{length(x) + length(y)}.
}
\description{
Returns a new \code{priority_queue} containing every entry from both inputs,
preserving each queue's internal insertion order (entries of \code{x} come
first, then entries of \code{y}).
}
\details{
The cached \code{.pq_min} / \code{.pq_max} monoids recompute automatically on the
merged tree, so \code{peek_min()} / \code{peek_max()} reflect the combined extremum
immediately.

Both queues must share the same priority type and the same monoid set;
mismatches error rather than being silently harmonized. Merging an
empty queue with a non-empty queue returns the non-empty queue unchanged.

Both inputs are left unmodified.
}
\examples{
a <- priority_queue("x", "y", priorities = c(5, 1))
b <- priority_queue("z", priorities = 3)
m <- merge(a, b)
peek_min(m)
length(m)
}
