MCPcopy Create free account
hub / github.com/SVF-tools/SVF / find_next

Method find_next

svf/include/Util/SparseBitVector.h:380–402  ·  view source on GitHub ↗

find_next - Returns the index of the next set bit starting from the "Curr" bit. Returns -1 if the next set bit is not found.

Source from the content-addressed store, hash-verified

378 /// find_next - Returns the index of the next set bit starting from the
379 /// "Curr" bit. Returns -1 if the next set bit is not found.
380 int find_next(unsigned Curr) const
381 {
382 if (Curr >= BITS_PER_ELEMENT)
383 return -1;
384
385 unsigned WordPos = Curr / BITWORD_SIZE;
386 unsigned BitPos = Curr % BITWORD_SIZE;
387 BitWord Copy = Bits[WordPos];
388 assert(WordPos <= BITWORDS_PER_ELEMENT
389 && "Word Position outside of element");
390
391 // Mask off previous bits.
392 Copy &= ~0UL << BitPos;
393
394 if (Copy != 0)
395 return WordPos * BITWORD_SIZE + countTrailingZeros(Copy);
396
397 // Check subsequent words.
398 for (unsigned i = WordPos+1; i < BITWORDS_PER_ELEMENT; ++i)
399 if (Bits[i] != 0)
400 return i * BITWORD_SIZE + countTrailingZeros(Bits[i]);
401 return -1;
402 }
403
404 // Union this element with RHS and return true if this one changed.
405 bool unionWith(const SparseBitVectorElement &RHS)

Callers 1

AdvanceToNextNonZeroMethod · 0.80

Calls 1

countTrailingZerosFunction · 0.85

Tested by

no test coverage detected