View source: R/40-priority_queue-queue-ops.R
| merge.priority_queue | R Documentation |
Returns a new priority_queue containing every entry from both inputs,
preserving each queue's internal insertion order (entries of x come
first, then entries of y).
## S3 method for class 'priority_queue'
merge(x, y, ...)
x |
A |
y |
A |
... |
Unused. |
The cached .pq_min / .pq_max monoids recompute automatically on the
merged tree, so peek_min() / 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.
A new priority_queue of size length(x) + length(y).
a <- priority_queue("x", "y", priorities = c(5, 1))
b <- priority_queue("z", priorities = 3)
m <- merge(a, b)
peek_min(m)
length(m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.