I need help with a generic Map that supports the insert and lookup operations. The implementation will store a hash table of pairs (key, definition). You will lookup a definition by providing a key. This is what I have so far. I don't know what is missing.
template <typename HashedObj, typename Object>
class Pair
{
HashedObj key;
Object def;
// Appropriate Constructors, etc.
};
template <typename HashedObj, typename Object>
class Dictionary
{
EDIT: Actually...why exactly would you want to "insert" something into a map...it's stored by a key so it doesn't matter where it is...if it is just adding something to it, you can do that with a normal map too...
Actually, you can do both of these with a normal map...
What's the difference between Dictionary and HashTable? A dictionary stores a relation between a unique key of type T and a value of type T2. A hashmap is a special case of a dictionary in which the keys are hashed before any indexing operation, and the hash is used as the key, instead. Where does Dictionary keep the keys?
Since a hashmap is a special case of a dictionary, it'd make more sense that HashMap had an instance of Dictionary, not viceversa.
Yeah, I agree with firedraco. insert() should be called add(), since you can't tell it where to insert.