// hashmap.h - public declarations for a simple hashmap

#ifndef __hashmap_h__
#define __hashmap_h__

typedef struct _HashmapEntry_ HashmapEntry;
typedef struct _Hashmap_ Hashmap;

// debug flag for the hashmap (for use with default_debug.h)
#define HASHMAP_DEBUG    0x02

//------------------------------------------------------------
// struct for the hash map and necessary access functions
struct _Hashmap_
{
  HashmapEntry **entries;
  unsigned modulus;
  unsigned (*hash_funct)(void *key,
                         unsigned modulus,
                         void (*error_handler)(int error_type,
                                               void *special));
  int (*compare_funct)(void *key1,
                       void *key2,
                       void (*error_handler)(int error_type,
                                             void *special));
};

Hashmap *newHashmap(unsigned modulus,
                    unsigned (*hash_funct)(
                      void *key,
                      unsigned modulus,
                      void (*error_handler)(int error_type,
                                            void *special)),
                    int (*compare_funct)(
                      void *key1,
                      void *key2,
                      void (*error_handler)(int error_type,
                                            void *special)),
                    void (*error_handler)(int error_type,
                                          void *special));
void deleteHashmap(Hashmap *map,
                   void (*error_handler)(int error_type,
                                         void *special));
void insertIntoHashmap(Hashmap *map,
                       void *key,
                       void *value,
                       void (*key_destructor)(
                         void *key,
                         void (*error_handler)(int error_type,
                                               void *special)),
                       void (*value_destructor)(
                         void *value,
                         void (*error_handler)(int error_type,
                                               void *special)),
                       void (*error_handler)(int error_type,
                                             void *special));
void *getFromHashmap(Hashmap *map,
                     void *key,
                     void (*error_handler)(int error_type,
                                           void *special));
void deleteFromHashmap(Hashmap *map,
                       void *key,
                       void (*error_handler)(int error_type,
                                             void *special));
                       
#endif // __hashmap_h__
