Submask 2026-11-05
A submask of a bit mask is a bit mask whose set bits are all set in , equivalently . It represents a subset of the positions selected by . If has set bits, it has exactly submasks, including zero.
To enumerate them in descending order, start at , output , stop if , and otherwise replace it by . Subtracting one clears the lowest set bit and fills lower positions; masking removes positions unavailable in . For , the sequence is . Testing for zero before the next update is essential: under the common integer conventions, updating zero produces again and repeats the cycle.[ref]
Enumerating submasks of a bitmask in the CP-Algorithms documentation. Enumerating all submasks of a given mask
The number of outputs is exponential in the number of selected positions, even though each fixed-word update is inexpensive.