Returns position of the next non-zero bit, which offset is greater than specified pos Typical loop for iterating bits: for (size_t pos = bits.FirstNonZeroBit(); pos != bits.Size(); pos = bits.NextNonZeroBit(pos)) { ... } See Y_FOR_EACH_BIT macro definition at the bottom
| 956 | // } |
| 957 | // See Y_FOR_EACH_BIT macro definition at the bottom |
| 958 | size_t NextNonZeroBit(size_t pos) const { |
| 959 | size_t i = (pos + 1) >> DivCount; |
| 960 | if (i < Mask.GetChunkCapacity()) { |
| 961 | const size_t offset = (pos + 1) & ModMask; |
| 962 | // Process the current chunk |
| 963 | if (offset) { |
| 964 | // Zero already iterated trailing bits using mask |
| 965 | const TChunk val = Mask.Data[i] & ((~TChunk(0)) << offset); |
| 966 | if (val) { |
| 967 | return BitsPerChunk * i + CountTrailingZeroBits(TIntType(val)); |
| 968 | } |
| 969 | // Continue with other chunks |
| 970 | ++i; |
| 971 | } |
| 972 | |
| 973 | for (; i < Mask.GetChunkCapacity(); ++i) { |
| 974 | if (Mask.Data[i]) { |
| 975 | return BitsPerChunk * i + CountTrailingZeroBits(TIntType(Mask.Data[i])); |
| 976 | } |
| 977 | } |
| 978 | } |
| 979 | return Size(); |
| 980 | } |
| 981 | |
| 982 | Y_FORCE_INLINE size_t Count() const { |
| 983 | size_t count = 0; |
no test coverage detected