Hash for class-wide key in Ada.Containers.Indefinite_Hashed_Maps

211 views Asked by At

I am in trouble trying to create an indefinite hashed map, as I want as a key specific objects that inherits from an abstract class, so the Key_Type is the parent class-wide, but I do not know what to do with the Hash that the container requires, as the Hash_Type is a modular type. How can I deal with the hash of a class-wide key?

1

There are 1 answers

9
Niklas Holsti On BEST ANSWER

First thing that comes to mind is to add a "Hash" primitive function to the Key_Type abstract class, to be implemented in each concrete derived key type using the components of that concrete type, and then to make the Hash function for the map call this primitive Hash function with redispatch according to the actual type of the key.