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

Class TBitMapOps

util/generic/bitmap.h:312–1040  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310
311template <class TTraits>
312class TBitMapOps {
313public:
314 using TChunk = typename TTraits::TChunk;
315 using TThis = TBitMapOps<TTraits>;
316
317private:
318 static_assert(std::is_unsigned<TChunk>::value, "expect std::is_unsigned<TChunk>::value");
319
320 static constexpr size_t BitsPerChunk = 8 * sizeof(TChunk);
321 static constexpr TChunk ModMask = static_cast<TChunk>(BitsPerChunk - 1);
322 static constexpr size_t DivCount = NBitMapPrivate::TDivCount<BitsPerChunk>::Value - 1;
323 static constexpr TChunk FullChunk = (TChunk)~TChunk(0);
324
325 template <class>
326 friend class TBitMapOps;
327
328 using TStorage = typename TTraits::TStorage;
329
330 // The smallest unsigned type that can be used in bit ops
331 using TIntType = std::conditional_t<sizeof(TChunk) < sizeof(unsigned int), unsigned int, TChunk>;
332
333 TStorage Mask;
334
335public:
336 class TReference {
337 private:
338 friend class TBitMapOps<TTraits>;
339
340 TChunk* Chunk;
341 size_t Offset;
342
343 TReference(TChunk* c, size_t offset)
344 : Chunk(c)
345 , Offset(offset)
346 {
347 }
348
349 public:
350 ~TReference() = default;
351
352 Y_FORCE_INLINE TReference& operator=(bool val) {
353 if (val) {
354 *Chunk |= static_cast<TChunk>(1) << Offset;
355 } else {
356 *Chunk &= ~(static_cast<TChunk>(1) << Offset);
357 }
358
359 return *this;
360 }
361
362 Y_FORCE_INLINE TReference& operator=(const TReference& ref) {
363 if (ref) {
364 *Chunk |= static_cast<TChunk>(1) << Offset;
365 } else {
366 *Chunk &= ~(static_cast<TChunk>(1) << Offset);
367 }
368
369 return *this;

Callers

nothing calls this directly

Calls 14

OrFunction · 0.85
SetDifferenceFunction · 0.85
ReserveFunction · 0.85
SwapFunction · 0.70
MinFunction · 0.70
TChunkClass · 0.50
SetClass · 0.50
ClearFunction · 0.50
ExpandBitSizeMethod · 0.45
GetChunkCapacityMethod · 0.45
GetBitCapacityMethod · 0.45
ValueBitCountMethod · 0.45

Tested by

no test coverage detected