src/gen/supset/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../util/alias/num/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | // enumerate x : $b \subset x \subset n$ | ||
| 8 | template <u32 = 0> | ||
| 9 | class enum_supset { | ||
| 10 | static inline u32 b_, n_; | ||
| 11 | u32 now_; | ||
| 12 | |||
| 13 | 32 | static CEXP u32 num_begin() NE { return b_; } | |
| 14 | 394332 | static CEXP u32 num_end() NE { return 1_u32 << n_; } | |
| 15 | |||
| 16 | public: | ||
| 17 | 16 | static CEXP void set(u32 b, u32 n) NE { | |
| 18 |
2/4✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
|
16 | assert((u32)std::countl_one(b) <= n && n < 32); |
| 19 | 16 | b_ = b, n_ = n; | |
| 20 | 16 | } | |
| 21 | 16 | static CEXP enum_supset begin() NE { return num_begin(); } | |
| 22 | 16 | static CEXP enum_supset end() NE { return num_end(); } | |
| 23 | |||
| 24 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
|
48 | CEXP enum_supset(u32 now = num_begin()) NE : now_(now) { assert(now <= num_end()); } |
| 25 | |||
| 26 | 1182836 | CEXP u32 operator*() CNE { return now_; } | |
| 27 | 394284 | CEXP bool operator!=(enum_supset CR x) CNE { return **this != *x; } | |
| 28 | 394268 | CEXP void operator++() NE { now_ = min((now_ + 1) | b_, num_end()); } | |
| 29 | }; | ||
| 30 | |||
| 31 | } // namespace tifa_libs | ||
| 32 |