nBitsToCount

Сount bits until set bit count is reached. Works with ndslices created with mir.ndslice.topology.bitwise, mir.ndslice.allocation.bitSlice.

  1. sizediff_t nBitsToCount(Slice!(FieldIterator!(BitField!(Field, I))) bitSlice, size_t count)
    @optmath
    sizediff_t
    nBitsToCount
    (
    Field
    I
    )
    (,
    size_t count
    )
  2. sizediff_t nBitsToCount(Slice!(RetroIterator!(FieldIterator!(BitField!(Field, I)))) bitSlice, size_t count)

Return Value

Type: sizediff_t

bit count if set bit count is reached or -1 otherwise.

Examples

import mir.ndslice.allocation: bitSlice;
import mir.ndslice.topology: retro;
auto s = bitSlice(1000);
s[50] = true;
s[100] = true;
s[200] = true;
s[300] = true;
s[400] = true;
assert(s.nBitsToCount(4) == 301);
assert(s.retro.nBitsToCount(4) == 900);

Meta