11 : hardware_index_{hardware_index}, capacity_{capacity}, color_set_{}, assigned_tile_ids_{},
12 cached_per_color_multiplicity_{}
24 return count >= capacity_ ? 0 : capacity_ - count;
40 assigned_tile_ids_.push_back(tile.
id());
45 for_each_color(tile.
color_set(), [
this](std::size_t color_idx) { cached_per_color_multiplicity_[color_idx]++; });
56 if (
const auto it = tile_colors_.find(tile_id); it != tile_colors_.end()) {
57 for_each_color(it->second, [
this](std::size_t color_idx) { cached_per_color_multiplicity_[color_idx]--; });
60 auto iter = std::ranges::find(assigned_tile_ids_, tile_id);
61 if (iter != assigned_tile_ids_.end()) {
62 assigned_tile_ids_.erase(iter);
64 tile_colors_.erase(tile_id);
68 for (
const auto &colors : tile_colors_ | std::views::values) {
A set of colors represented as a bitset.
Wraps a ColorSet with a tile ID for tracking during palette packing.
const ColorSet & color_set() const
std::variant< HintId, PrefilledPaletteId, RegularId, AnimId, PrimaryTileId > Id
Variant type for tile identification.
void remove_tile(const PackableTile &tile)
Removes a tile from this palette and recalculates the color set.
std::size_t union_size(const ColorSet &tile_colors) const
Computes the size of the union of this palette's colors with the given colors.
bool can_fit(const ColorSet &tile_colors) const
Checks if a tile's colors can fit in this palette.
void add_tile(const PackableTile &tile)
Adds a tile to this palette.
std::size_t remaining_capacity() const
PackedPalette(std::size_t hardware_index, std::size_t capacity=pal::max_size - 1)
Constructs a PackedPalette with a given index and capacity.
std::size_t color_count() const
void for_each_color(const ColorSet &set, Func &&func)
Iterates over each color index in a ColorSet.
ColorSet color_set_union(const ColorSet &a, const ColorSet &b)
Computes the union of two ColorSets.
std::size_t color_set_count(const ColorSet &set)
Counts the number of colors in a ColorSet.