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.
std.algorithm.mutation.reverse
- multiple declarations
- Function reverse
- Function reverse
Function reverse
Reverses
in-place. Performs r
r.length / 2
evaluations of
.
swap
Prototypes
void reverse(Range)( Range r ) if (isBidirectionalRange!Range && !isRandomAccessRange!Range && hasSwappableElements!Range); void reverse(Range)( Range r ) if (isRandomAccessRange!Range && hasLength!Range);
See Also
Example
int[] arr = [ 1, 2, 3 ]; reverse(arr); assert(arr == [ 3, 2, 1 ]);
Function reverse
Reverses r
in-place, where r
is a narrow string (having
elements of type char
or wchar
). UTF sequences consisting of
multiple code units are preserved properly.
Prototype
void reverse(Char)( Char[] s ) if (isNarrowString!(Char[]) && !is(Char == const) && !is(Char == immutable));
Example
char[] arr = "hello\U00010143\u0100\U00010143".dup; reverse(arr); assert(arr == "\U00010143\u0100\U00010143olleh");