The OpenD Programming Language

retroNBitsToCount

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

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

Return Value

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