36 [[nodiscard]]
const std::bitset<num_colors> &
colors()
const
44 std::bitset<num_colors> colors_;
132template <
typename Func>
135 static_assert(
num_colors % 64 == 0,
"num_colors must be a multiple of 64 for efficient word-aligned bit scanning");
137 const auto &bits = set.
colors();
146 constexpr std::size_t words = (
num_colors + 63) / 64;
148 for (std::size_t word = 0; word < words; ++word) {
150 std::uint64_t chunk = 0;
151 const std::size_t base = word * 64;
152 for (std::size_t b = 0; b < 64 && (base + b) <
num_colors; ++b) {
153 if (bits.test(base + b)) {
154 chunk |= (1ULL << b);
161 const int bit = __builtin_ctzll(chunk);
162 func(base +
static_cast<std::size_t
>(bit));
190 return std::hash<std::string>{}(color_set.colors().to_string());
Represents a color index value for palette operations.
A set of colors represented as a bitset.
const std::bitset< num_colors > & colors() const
void reset(ColorIndex index)
bool operator==(const ColorSet &other) const =default
void set(ColorIndex index, bool value=true)
bool test(ColorIndex index) const
constexpr std::size_t num_pals
constexpr std::size_t max_size
void for_each_color(const ColorSet &set, Func &&func)
Iterates over each color index in a ColorSet.
bool is_subset(const ColorSet &a, const ColorSet &b)
Checks if one ColorSet is a subset of another.
ColorSet color_set_union(const ColorSet &a, const ColorSet &b)
Computes the union of two ColorSets.
constexpr std::size_t num_colors
Maximum allowable color count for GBA hardware.
ColorSet color_set_intersection(const ColorSet &a, const ColorSet &b)
Computes the intersection of two ColorSets.
std::size_t intersection_size(const ColorSet &a, const ColorSet &b)
Computes the intersection size between two ColorSets.
std::size_t color_set_count(const ColorSet &set)
Counts the number of colors in a ColorSet.
std::size_t union_size(const ColorSet &a, const ColorSet &b)
Computes the union size of two ColorSets.
std::size_t operator()(const porytiles::ColorSet &color_set) const noexcept
Computes the hash value for a ColorSet.