View source code Display the source code in std/algorithm/mutation.d from which this page was generated on github. 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. Page wiki View or edit the community-maintained wiki page associated with this page.

Function std.algorithm.mutation.moveSome

For each element a in src and each element b in tgt in lockstep in increasing order, calls move(a, b). Stops when either src or tgt have been exhausted.

Prototype

Tuple!(Range1,Range2) moveSome(Range1, Range2)(
  Range1 src,
  Range2 tgt
)
if (isInputRange!Range1 && isInputRange!Range2 && is(typeof(move(src.front, tgt.front))));

Parameters

NameDescription
src An input range with movable elements.
tgt An input range with elements that elements from src can be moved into.

Returns

The leftover portions of the two ranges after one or the other of the ranges have been exhausted.

Example

int[] a = [ 1, 2, 3, 4, 5 ];
int[] b = new int[3];
assert(moveSome(a, b)[0] is a[3 .. $]);
assert(a[0 .. 3] == b);
assert(a == [ 1, 2, 3, 4, 5 ]);

Authors

Andrei Alexandrescu

License

Boost License 1.0.

Comments