8 : available_indexes_{available_indexes}, checked_out_{}, checkout_stack_{}
15 panic(
"index out of bounds");
17 return available_indexes_.test(hardware_index) && !checked_out_.test(hardware_index);
23 panic(
"called with no available indexes");
28 if (available_indexes_.test(i) && !checked_out_.test(i)) {
30 checkout_stack_.push_back(i);
36 panic(
"unreachable state");
42 panic(
"index is not available for checkout");
45 checked_out_.set(index);
46 checkout_stack_.push_back(index);
51 if (checkout_stack_.empty()) {
52 panic(
"called with empty checkout stack");
55 std::size_t index = checkout_stack_.back();
56 checkout_stack_.pop_back();
57 checked_out_.reset(index);
std::size_t checkout()
Checks out the next available hardware palette index.
void checkin()
Returns the most recently checked-out hardware palette index index to the pool.
PalettePool(std::bitset< pal::num_pals > available_indexes)
Constructs a PalettePool with the specified available indexes.
bool is_available(std::size_t hardware_index) const
Checks if a specific index is available for checkout.
bool has_available_pal() const
Checks if there is at least one available pal that can be checked out.
constexpr std::size_t num_pals
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.