12 #ifndef EMP_SOLVE_STATE_H 13 #define EMP_SOLVE_STATE_H 15 #include "../base/assert.h" 33 SolveState(
size_t state_size=0) : in_items(state_size), unk_items(state_size) {
41 in_items = in.in_items;
42 unk_items = in.unk_items;
51 bool IsIn(
size_t id)
const {
return in_items[id]; }
55 bool IsUnk(
size_t id)
const {
return unk_items[id]; }
84 return unk_items.
FindBit(prev_unk+1);
90 unk_items.
Set(
id,
false);
91 in_items.
Set(
id,
true);
97 unk_items.
Set(
id,
false);
103 unk_items.
Set(
id,
false);
104 in_items.
Set(
id,
false);
111 unk_items &= ~inc_set;
117 unk_items &= ~inc_set;
void SetAll()
Set all bits to 1.
Definition: BitVector.h:484
size_t size() const
Function to allow drop-in replacement with std::vector<bool>.
Definition: BitVector.h:765
size_t CountOnes() const
Count the number of ones in the BitVector.
Definition: BitVector.h:544
bool IsUnk(size_t id) const
Definition: SolveState.h:55
~SolveState()
Definition: SolveState.h:37
A drop-in replacement for std::vector<bool>, but with extra bitwise logic features.
Definition: BitVector.h:39
A drop-in replacement for std::vector<bool>, with additional bitwise logic features.
void IncludeSet(const BitVector &inc_set)
Include ALL of the items specified in the provided BitVector.
Definition: SolveState.h:108
bool None() const
Return true if NO bits are set to 1, otherwise return false.
Definition: BitVector.h:463
int FindBit() const
Return the position of the first one; return -1 if no ones in vector.
Definition: BitVector.h:547
size_t CountIn() const
How many items have been included for sure?
Definition: SolveState.h:65
int GetNextUnk(size_t prev_unk) const
Get the ID of the next unknown item.
Definition: SolveState.h:83
size_t CountOut() const
How many items have been excluded for sure.
Definition: SolveState.h:71
void Exclude(size_t id)
Mark a specific item as to be excluded.
Definition: SolveState.h:95
SolveState & operator=(const SolveState &in)
Set this SolveState to be identical to another.
Definition: SolveState.h:40
bool IsOut(size_t id) const
Definition: SolveState.h:59
SolveState(size_t state_size=0)
Definition: SolveState.h:33
const BitVector & GetInVector() const
Get the BitVector associated with which items have been included for sure.
Definition: SolveState.h:74
bool IsFinal() const
Test if all items have been decided upon (none are still in the "unknown" state)
Definition: SolveState.h:62
void Include(size_t id)
Mark a specific item as to be included.
Definition: SolveState.h:88
SolveState(const SolveState &in)
Definition: SolveState.h:36
void ExcludeSet(const BitVector &inc_set)
Exclude ALL of the items specified in the provided BitVector.
Definition: SolveState.h:115
size_t GetSize() const
How many items are being considered in the current SolveState?
Definition: SolveState.h:47
If we are in emscripten, make sure to include the header.
Definition: array.h:37
bool IsIn(size_t id) const
Definition: SolveState.h:51
size_t CountUnk() const
How many items have yet to be decided upon (are "unknown")
Definition: SolveState.h:68
#define emp_assert(...)
Definition: assert.h:199
Definition: SolveState.h:27
void ForceExclude(size_t id)
Definition: SolveState.h:102
BitVector GetOutVector() const
Get the BitVector associated with which iterm have been excluded for sure.
Definition: SolveState.h:80
void Set(size_t index, bool value=true)
Update the bit value at the specified index.
Definition: BitVector.h:379
const BitVector & GetUnkVector() const
Get the BitVector associated with which items have yet to be decided upon.
Definition: SolveState.h:77
size_t GetSize() const
How many bits do we currently have?
Definition: BitVector.h:368