View source code
Display the source code in std/bitmanip.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.

std.bitmanip.BitArray.flip - multiple declarations

Function BitArray.flip

Flips all the bits in the BitArray

void flip() pure nothrow @nogc;

Example

import std.algorithm.comparison : equal;
import std.range : iota;

// positions 0, 2, 4 are set
auto b = BitArray([1, 0, 1, 0, 1, 0]);
b.flip();
// after flipping, positions 1, 3, 5 are set
assert(b.bitsSet.equal([1, 3, 5]));

bool[270] bits;
auto b1 = BitArray(bits);
b1.flip();
assert(b1.bitsSet.equal(iota(0, 270)));

Function BitArray.flip

Flips a single bit, specified by pos

void flip (
  ulong i
) pure nothrow @nogc;

Example

auto ax = BitArray([1, 0, 0, 1]);
ax.flip(0);
writeln(ax[0]); // 0

bool[200] y;
y[90 .. 130] = true;
auto ay = BitArray(y);
ay.flip(100);
writeln(ay[100]); // 0

Authors

Walter Bright, Andrei Alexandrescu, Jonathan M Davis, Alex Rønne Petersen, Damian Ziemba, Amaury SECHET

License

Boost License 1.0.