core.bitop
This module contains a collection of bit-level operations.
Copyright
Copyright Don Clugston 2005 - 2013.
Types 4
private aliassoftBsf(N) = softScan!(N, true)
private aliassoftBsr(N) = softScan!(N, false)
structBitRange
Range over bit set. Each element is the bit number that is set.
This is more efficient than testing each bit in a sparsely populated bit set. Note that the first bit in the bit set would be bit 0.
Fields
size_t.sizeof * 8 bitsPerWordNumber of bits in each size_tconst(size_t) *bits bitssize_t cursize_t idxsize_t lenConstructors
this(const(size_t) * bitarr, size_t numBits)Construct a BitRange.Functions 22
fn
int bsf(uint v) pureScans the bits in v starting with bit 0, looking for the first set bit. Returns: The bit number of the first bit set. The return value is undefined if v is zero.fn
int bsr(uint v) pureScans the bits in v from the most significant bit to the least significant bit, looking for the first set bit. Returns: The bit number of the first bit set. The return value is undefined if v is zero.fn
int bt(const scope size_t * p, size_t bitnum) pure @systemTests the bit. (No longer an intrisic - the compiler recognizes the patterns in the body.)fn
int bts(size_t * p, size_t bitnum) pure @system Tests and sets the bit. Params: p = a non-NULL pointer to an array of sizets. bitnum = a bit number, starting with bit 0 of p[0], and progressing. It addresses bits like the expression: --- p[...fn
ushort byteswap(ushort x) pureSwaps bytes in a 2 byte ushort. Params: x = value Returns: `x` with bytes swappedfn
uint bswap(uint v) pure;Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 becomes byte 0.fn
ulong bswap(ulong v) pure;Swaps bytes in an 8 byte ulong end-to-end, i.e. byte 0 becomes byte 7, byte 1 becomes byte 6, etc. This is meant to be recognized by the compiler as an intrinsic.fn
T rol(T)(const T value, const uint count) if (__traits(isIntegral, T) && __traits(isUnsigned, T)) pureBitwise rotate `value` left (`rol`) or right (`ror`) by `count` bit positions.fn
T ror(T)(const T value, const uint count) if (__traits(isIntegral, T) && __traits(isUnsigned, T)) puredittofn
T rol(uint count, T)(const T value) if (__traits(isIntegral, T) && __traits(isUnsigned, T)) puredittofn
T ror(uint count, T)(const T value) if (__traits(isIntegral, T) && __traits(isUnsigned, T)) pureditto