| 334 | |
| 335 | public: |
| 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; |
| 370 | } |
| 371 | |
| 372 | Y_FORCE_INLINE bool operator~() const { |
| 373 | return 0 == (*Chunk & (static_cast<TChunk>(1) << Offset)); |
| 374 | } |
| 375 | |
| 376 | Y_FORCE_INLINE operator bool() const { |
| 377 | return 0 != (*Chunk & (static_cast<TChunk>(1) << Offset)); |
| 378 | } |
| 379 | |
| 380 | Y_FORCE_INLINE TReference& Flip() { |
| 381 | *Chunk ^= static_cast<TChunk>(1) << Offset; |
| 382 | return *this; |
| 383 | } |
| 384 | }; |
| 385 | |
| 386 | private: |
| 387 | struct TSetOp { |