unittest/sudokucelltest.cpp
// Returns true if only 1 bit is set (equal to 1), or false otherwise.
Returns true if only 1 bit is set (equal to 1), or false otherwise.
Returns true if only 1 bit is set ( equal to 1 ) or false otherwise .
bool SudokuCellTest::isUniqueCandidates(SudokuCellCandidates candidates) {
    auto result = false;
    auto restCandidates = candidates;
    for(size_t i=0; i < bitsOf(restCandidates); ++i) {
        if ((restCandidates & 1) == 1) {
            if (result != false) {
                return false;
            } else {
                result = true;
            }
        }
        restCandidates >>= 1;
    }
    return result;
}
bool SudokuCellTest :: isUniqueCandidates ( SudokuCellCandidates candidates ) { auto result = false ; auto restCandidates = candidates ; for ( size_t i = 0 ; i < bitsOf ( restCandidates ) ; ++ i ) { if ( ( restCandidates & 1 ) == 1 ) { if ( result != false ) { return false ; } else { result = true ; } } restCandidates >>= 1 ; } return result ; }
Returns true if only 1 bit is set (equal to 1), or false otherwise.
Returns true if only 1 bit is set ( equal to 1 ) or false otherwise .
// 2 bits are equal to 1 // a bit that equals to 1 is found