The OpenD Programming Language

swapAt

Swaps two elements in-place of a range r, specified by their indices i1 and i2.

void
swapAt
(
R
)
(
auto ref R r
,
size_t i1
,
size_t i2
)

Parameters

r R

a range with swappable elements

i1 size_t

first index

i2 size_t

second index

Examples

import std.algorithm.comparison : equal;
auto a = [1, 2, 3];
a.swapAt(1, 2);
assert(a.equal([1, 3, 2]));

Meta