![]() |
Cluedo Solver v1.0
Cluedo game solver making deductions.
|
A set of cards. More...
#include <CardSet.hpp>
Classes | |
| class | iterator |
| An iterator for the CardSet class. More... | |
Public Member Functions | |
| constexpr | CardSet ()=default |
| Constructs an empty set. | |
| constexpr | CardSet (std::initializer_list< Card > cards) |
| constexpr | CardSet (std::bitset< CardUtils::CARD_COUNT > set) |
| constexpr std::size_t | size () const |
| constexpr bool | empty () const |
| constexpr bool | contains (Card card) const |
| constexpr bool | insert (Card card) |
| constexpr void | erase (Card card) |
| constexpr void | clear () |
| Clears the set. | |
| constexpr bool | operator== (CardSet const &other) const =default |
| constexpr bool | operator!= (CardSet const &other) const =default |
| constexpr CardSet & | set_union (CardSet const &other) |
| constexpr bool | is_subset (CardSet const &other) const |
| constexpr iterator | begin () const |
| Returns an iterator to the first card of the set. | |
| constexpr iterator | end () const |
| Returns an iterator to the last card of the set. | |
Static Public Member Functions | |
| static constexpr CardSet | intersection (CardSet const &a, CardSet const &b) |
A set of cards.
This class is an optimization of what would have otherwise been std::unordered_set<Card>. Knowing that the number of cards in a Cluedo game is fixed and small we can use a std::bitset (which will probably fit in a single 32-bit integer) to store the cards.
|
inlineconstexpr |
Constructs a set with the given cards.
| cards | The list of cards that set will contain. |
|
inlineconstexpr |
Constructs a set with the given bitset.
| set | The bitset that the set will contain. |
|
inlineconstexpr |
Checks if the set contains the given card.
| card | The card to check. |
true if the set contains the card, false otherwise.
|
inlineconstexpr |
Checks if the set is empty.
true if the set is empty, false otherwise.
|
inlineconstexpr |
Removes a card from the set.
| card | The card to remove. |
|
inlineconstexpr |
Inserts a card into the set.
| card | The card to insert. |
true if the card was already in the set, false otherwise.
|
inlinestaticconstexpr |
Computes the intersection of two sets.
| a | The first set. |
| b | The second set. |
|
inlineconstexpr |
Checks if the set is a subset of another set.
| other | The other set. |
true if the set is a subset of the other set, false otherwise.
|
constexprdefault |
Compares two sets.
| other | The other set. |
true if the sets are not equal, false otherwise.
|
constexprdefault |
Compares two sets.
| other | The other set. |
true if the sets are equal, false otherwise. Computes the union of two sets.
| other | The other set |
|
inlineconstexpr |
Returns the number of cards in the set.