MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / find_last_not_set

Method find_last_not_set

source/MRMesh/MRBitSet.cpp:236–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236BitSet::IndexType BitSet::find_last_not_set() const
237{
238 if ( blocks_.empty() )
239 return npos;
240
241 auto lastBit = bitIndex_( numBits_ );
242 auto block = blocks_.back();
243 if ( lastBit != 0 )
244 block |= ~( ( block_type( 1 ) << lastBit ) - 1 );
245 if ( block != ~block_type( 0 ) )
246 return blocks_.size() * bits_per_block - std::countl_one( block ) - 1;
247 for ( int i = int( blocks_.size() ) - 2; i >= 0; --i )
248 {
249 if ( blocks_[i] == ~block_type( 0 ) )
250 continue;
251 return ( i + 1 ) * bits_per_block - std::countl_one( blocks_[i] ) - 1;
252 }
253 return npos;
254}
255
256size_t BitSet::nthSetBit( size_t n ) const
257{

Callers 2

TESTFunction · 0.45
findNonSetBitSetBoundsFunction · 0.45

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.36