StaticBitArray.reverse

Reverses the bits of the StaticBitArray in place.

struct StaticBitArray(uint capacity, Block = DefaultBlock)
@safe @property
typeof(this)
reverse
()
()
out (result) { assert (result == this); }
if (
isUnsigned!DefaultBlock
)

Examples

enum capacity = 64;
static immutable bool[capacity] data = [0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0];
auto b = StaticBitArray!capacity(data);
b.reverse();
for (size_t i = 0; i < data.length; ++i)
{
    assert(b[i] == data[capacity - 1 - i]);
}
enum capacity = 64*2;
static immutable bool[capacity] data = [0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0];
auto b = StaticBitArray!capacity(data);
b.reverse();
for (size_t i = 0; i < data.length; ++i)
{
    assert(b[i] == data[capacity - 1 - i]);
}
enum capacity = 64*3;
static immutable bool[capacity] data = [0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0,
                                   0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0, 0,1,1,0,1,0,1,0];
auto b = StaticBitArray!capacity(data);
b.reverse();
for (size_t i = 0; i < data.length; ++i)
{
    assert(b[i] == data[capacity - 1 - i]);
}

Meta