On Fri, Feb 07, 2025 at 06:37:40PM +0100, Colin Blundell wrote:
> I'd like to change it to be keyed by gfx::Size, which
> currently neither has hashing traits for wtf::HashMap nor the necessary
> comparators for std::map. Before investing in changing either of those
> things, I'm wondering: What would folks' recommendations be for the best
> change to make here?
If you have max 50 elements, and _especially_ if your typical number is lower
than that, then consider simply a Vector<pair<Size, Value>>. Gives small code
for lookup and insert, and unless your Value is very big (gfx::Size is just
comparing two ints, right?), zooming through them is fast.
Otherwise, you'd usually want HashMap over map. Make your own traits for
hashing, which should be fairly simple for Size.
/* Steinar */
--
Homepage:
https://www.sesse.net/