MCPcopy Create free account
hub / github.com/catboost/catboost / NextNonZeroBit

Method NextNonZeroBit

util/generic/bitmap.h:958–980  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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;

Callers 2

FindNextMethod · 0.80
Y_UNIT_TESTFunction · 0.80

Calls 4

CountTrailingZeroBitsFunction · 0.85
TChunkClass · 0.50
SizeFunction · 0.50
GetChunkCapacityMethod · 0.45

Tested by

no test coverage detected