diff --git a/agb-image-converter/src/colour.rs b/agb-image-converter/src/colour.rs index 3f12001e..c5e47a37 100644 --- a/agb-image-converter/src/colour.rs +++ b/agb-image-converter/src/colour.rs @@ -1,6 +1,6 @@ use std::{fmt, str::FromStr}; -#[derive(Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Colour { pub r: u8, pub g: u8, diff --git a/agb-image-converter/src/deduplicator.rs b/agb-image-converter/src/deduplicator.rs index 92498b6d..f96dec7f 100644 --- a/agb-image-converter/src/deduplicator.rs +++ b/agb-image-converter/src/deduplicator.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, hash::BuildHasher}; +use std::collections::BTreeMap; use crate::{colour::Colour, image_loader::Image}; @@ -42,7 +42,7 @@ pub struct DeduplicatedData { pub transformation: Transformation, } -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] struct Tile { data: [Colour; 64], } @@ -99,9 +99,7 @@ pub(crate) fn deduplicate_image(input: &Image, can_flip: bool) -> (Image, Vec (Image, Vec, } @@ -156,7 +159,7 @@ impl Palette16Optimiser { palette.add_colour(transparent_colour); palette }) - .collect::>() + .collect::>() .into_iter() .map(|palette| palette.colours) .collect::>(); diff --git a/agb-image-converter/src/palette256.rs b/agb-image-converter/src/palette256.rs index 8283081b..33d77b09 100644 --- a/agb-image-converter/src/palette256.rs +++ b/agb-image-converter/src/palette256.rs @@ -1,4 +1,4 @@ -use std::collections::HashSet; +use std::collections::BTreeSet; use crate::{ colour::Colour, @@ -7,13 +7,13 @@ use crate::{ }; pub struct Palette256 { - colours: HashSet, + colours: BTreeSet, } impl Palette256 { pub fn new() -> Self { Self { - colours: HashSet::new(), + colours: BTreeSet::new(), } } @@ -41,8 +41,8 @@ impl Palette256 { .cloned() .collect(); - let current_colours_set = HashSet::from_iter(optimised_palette_colours.iter().cloned()); - let new_colours: HashSet<_> = self + let current_colours_set = BTreeSet::from_iter(optimised_palette_colours.iter().cloned()); + let new_colours: BTreeSet<_> = self .colours .symmetric_difference(¤t_colours_set) .collect();