Utilities on bitsets. More...
Functions | |
void | BitsetToBytes (const bitset_t &b, byte *out, int numbits) |
Converts the bottom numbits of b into a byte stream. | |
bitset_t | BytesToBitset (const byte *bytes, int numbits) |
Converts a byte stream into a bitset. | |
std::string | BitsetToHex (const bitset_t &b, int numbits) |
Converts a bitset into a string of hex symbols. | |
bitset_t | HexToBitset (const std::string &str) |
Converts a string of hex symbols into a bitset. | |
bitset_t | Subtract (const bitset_t &b1, const bitset_t &b2) |
Subtracts b2 from b1. | |
bool | SubtractIfLeavesAny (bitset_t &removeFrom, const bitset_t &remove) |
If removeFrom - remove is not empty, stores that value in removeFrom and returns true. | |
bool | IsSubsetOf (const bitset_t &b1, const bitset_t &b2) |
Returns true if b1 is a subset of b2. | |
bool | IsLessThan (const bitset_t &b1, const bitset_t &b2) |
Returns true if b1 comes before b2 in some consistent order (any well defined ordering, not necessarily lexicographic). | |
template<typename INT > | |
void | BitsetToVector (const bitset_t &b, std::vector< INT > &indices) |
Stores indices of set bits in b in indices. | |
template<typename INT > | |
bitset_t | SetToBitset (const std::set< INT > &indices) |
Converts of set of indices into a bitset with those bits set. | |
int | FindSetBit (const bitset_t &b) |
Returns the bit that is set in b. | |
int | FirstSetBit (const bitset_t &b) |
Returns least-significant set bit in b. |
Utilities on bitsets.
Converts the bottom numbits of b into a byte stream.
std::string BitsetUtil::BitsetToHex | ( | const bitset_t & | b, | |
int | numbits | |||
) |
Converts a bitset into a string of hex symbols.
void BitsetUtil::BitsetToVector | ( | const bitset_t & | b, | |
std::vector< INT > & | indices | |||
) | [inline] |
Stores indices of set bits in b in indices.
Definition at line 131 of file Bitset.hpp.
References BITSETSIZE, benzene_bitset< _Nb >::count(), and benzene_bitset< _Nb >::test().
Referenced by HexUctPolicy::InitializeForRollout(), ProofUtil::StoreTranspositions(), and VCUtils::ValidEdgeBridge().
Converts a byte stream into a bitset.
Definition at line 27 of file Bitset.cpp.
References benzene_bitset< _Nb >::set().
int BitsetUtil::FindSetBit | ( | const bitset_t & | b | ) |
Returns the bit that is set in b.
Referenced by BenzenePlayer::CheckEndgame().
int BitsetUtil::FirstSetBit | ( | const bitset_t & | b | ) |
Returns least-significant set bit in b.
Referenced by BoardUtils::FindSplittingDecomposition().
bitset_t BitsetUtil::HexToBitset | ( | const std::string & | str | ) |
Converts a string of hex symbols into a bitset.
Definition at line 58 of file Bitset.cpp.
References benzene_bitset< _Nb >::set().
Returns true if b1 comes before b2 in some consistent order (any well defined ordering, not necessarily lexicographic).
Definition at line 167 of file Bitset.hpp.
References BITSETSIZE, and benzene_bitset< _Nb >::is_less_than().
Referenced by VC::operator<().
Returns true if b1 is a subset of b2.
Definition at line 158 of file Bitset.hpp.
References benzene_bitset< _Nb >::is_subset_of().
Referenced by HexBoard::AddStones(), VC::AndVCs(), VCBuilder::doAnd(), ConstBoard::IsCell(), ConstBoard::IsLocation(), VC::isSubsetOf(), VCList::isSubsetOfAny(), VCList::isSupersetOfAny(), ConstBoard::IsValid(), VCPattern::Matches(), VCBuilder::OrRule::operator()(), DfsSolver::OrderMoves(), MoHexPlayer::PerformPreSearch(), HexBoard::PlayStones(), VCList::removeSuperSetsOf(), ProofUtil::StoreFlippedStates(), and Pattern::unserialize().
bitset_t BitsetUtil::SetToBitset | ( | const std::set< INT > & | indices | ) | [inline] |
Converts of set of indices into a bitset with those bits set.
Definition at line 143 of file Bitset.hpp.
References benzene_bitset< _Nb >::set().
Referenced by InferiorCells::AddDominatedFrom(), InferiorCells::Dominated(), and InferiorCells::RemoveDominated().