View source code
Display the source code in std/algorithm/mutation.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.mutation.swapRanges
Swaps all elements of r1
with successive elements in r2
.
Returns a tuple containing the remainder portions of r1
and r2
that were not swapped (one of them will be empty). The ranges may
be of different types but must have the same element type and support
swapping.
Tuple!(InputRange1,InputRange2) swapRanges(InputRange1, InputRange2)
(
InputRange1 r1,
InputRange2 r2
)
if (hasSwappableElements!InputRange1 && hasSwappableElements!InputRange2 && is(ElementType!InputRange1 == ElementType!InputRange2));
Parameters
Name | Description |
---|---|
r1 | an input range with swappable elements |
r2 | an input range with swappable elements |
Returns
Tuple containing the remainder portions of r1 and r2 that were not swapped
Example
import std .range : empty;
int[] a = [ 100, 101, 102, 103 ];
int[] b = [ 0, 1, 2, 3 ];
auto c = swapRanges(a[1 .. 3], b[2 .. 4]);
assert(c[0] .empty && c[1] .empty);
writeln(a); // [100, 2, 3, 103]
writeln(b); // [0, 1, 101, 102]
Authors
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.