The OpenD Programming Language

BitArray.flip

Flips all the bits in the BitArray

  1. void flip()
    struct BitArray
    @nogc pure nothrow @system
    void
    flip
    ()
  2. void flip(size_t pos)

Examples

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)));

Meta