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.opSliceAssign
- multiple declarations
Function BitArray.opSliceAssign
Sets all the values in the BitArray
to the
value specified by val
.
void opSliceAssign
(
bool val
);
Example
import std .algorithm .comparison : equal;
auto b = BitArray([1, 0, 1, 0, 1, 1]);
b[] = true;
// all bits are set
assert(b .bitsSet .equal([0, 1, 2, 3, 4, 5]));
b[] = false;
// none of the bits are set
assert(b .bitsSet .empty);
Function BitArray.opSliceAssign
Sets the bits of a slice of BitArray
starting
at index start
and ends at index ($D end - 1)
with the values specified by val
.
void opSliceAssign
(
bool val,
ulong start,
ulong end
);
Example
import std .algorithm .comparison : equal;
import std .range : iota;
import std .stdio;
auto b = BitArray([1, 0, 0, 0, 1, 1, 0]);
b[1 .. 3] = true;
assert(b .bitsSet .equal([0, 1, 2, 4, 5]));
bool[72] bitArray;
auto b1 = BitArray(bitArray);
b1[63 .. 67] = true;
assert(b1 .bitsSet .equal([63, 64, 65, 66]));
b1[63 .. 67] = false;
assert(b1 .bitsSet .empty);
b1[0 .. 64] = true;
assert(b1 .bitsSet .equal(iota(0, 64)));
b1[0 .. 64] = false;
assert(b1 .bitsSet .empty);
bool[256] bitArray2;
auto b2 = BitArray(bitArray2);
b2[3 .. 245] = true;
assert(b2 .bitsSet .equal(iota(3, 245)));
b2[3 .. 245] = false;
assert(b2 .bitsSet .empty);
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, Alex Rønne Petersen, Damian Ziemba, Amaury SECHET
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.