View source code
Display the source code in std/algorithm/setops.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.algorithm.setops.multiwayUnion
Computes the union of multiple ranges. The
input ranges are passed
as a range of ranges and each is assumed to be sorted by less
. Computation is done lazily, one union element at a time.
multiwayUnion(ror)
is functionally equivalent to multiwayMerge(ror)
.
auto multiwayUnion(alias less, RangeOfRanges)
(
RangeOfRanges ror
);
"The output of multiwayUnion has no duplicates even when its inputs contain duplicates."
Parameters
Name | Description |
---|---|
less | Predicate the given ranges are sorted by. |
ror | A range of ranges sorted by less to compute the intersection for. |
Returns
A range of the union of the ranges in ror
.
See also: multiwayMerge
Example
import std .algorithm .comparison : equal;
// sets
double[][] a =
[
[ 1, 4, 7, 8 ],
[ 1, 7 ],
[ 1, 7, 8],
[ 4 ],
[ 7 ],
];
auto witness = [1, 4, 7, 8];
assert(equal(multiwayUnion(a), witness));
// multisets
double[][] b =
[
[ 1, 1, 1, 4, 7, 8 ],
[ 1, 7 ],
[ 1, 7, 7, 8],
[ 4 ],
[ 7 ],
];
assert(equal(multiwayUnion(b), witness));
double[][] c =
[
[9, 8, 8, 8, 7, 6],
[9, 8, 6],
[9, 8, 5]
];
auto witness2 = [9, 8, 7, 6, 5];
assert(equal(multiwayUnion!"a > b"(c), witness2));
Authors
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.