View source: R/50-ordered_sequence-ops.R
| merge.ordered_sequence | R Documentation |
Returns a new ordered_sequence containing every entry from both inputs,
preserving key order. On duplicate keys, x's entries precede y's
(left-biased FIFO).
## S3 method for class 'ordered_sequence'
merge(x, y, ...)
x |
An |
y |
An |
... |
Unused. |
The merge runs in O(m + n) via a zipper-style traversal, with a fast path
to O(log(min(m, n))) when the key ranges are disjoint (all of x's keys
<= all of y's keys, or vice versa with a strict < to keep
left-biased FIFO intact on equal boundary keys).
Both sequences must share the same key type and the same monoid set; mismatches error rather than being silently harmonized. Merging an empty sequence with a non-empty sequence returns the non-empty one unchanged.
Both inputs are left unmodified.
A new ordered_sequence of size length(x) + length(y).
a <- ordered_sequence("a1", "a2", "a3", keys = c(1, 3, 5))
b <- ordered_sequence("b1", "b2", "b3", keys = c(2, 3, 6))
m <- merge(a, b)
as.list(m)
# At the tied key 3, "a2" precedes "b2".
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.