nakedmud-mod/
nakedmud-mod/html/tutorials/
nakedmud-mod/html/tutorials/building_extras/
nakedmud-mod/html/tutorials/c/
nakedmud-mod/html/tutorials/reference/
nakedmud-mod/html/tutorials/scripting/
nakedmud-mod/html/tutorials/scripting_extras/
nakedmud-mod/lib/
nakedmud-mod/lib/help/A/
nakedmud-mod/lib/help/B/
nakedmud-mod/lib/help/C/
nakedmud-mod/lib/help/D/
nakedmud-mod/lib/help/G/
nakedmud-mod/lib/help/H/
nakedmud-mod/lib/help/J/
nakedmud-mod/lib/help/L/
nakedmud-mod/lib/help/M/
nakedmud-mod/lib/help/O/
nakedmud-mod/lib/help/P/
nakedmud-mod/lib/help/R/
nakedmud-mod/lib/help/S/
nakedmud-mod/lib/help/W/
nakedmud-mod/lib/logs/
nakedmud-mod/lib/misc/
nakedmud-mod/lib/players/
nakedmud-mod/lib/pymodules/polc/
nakedmud-mod/lib/txt/
nakedmud-mod/lib/world/
nakedmud-mod/lib/world/zones/examples/
nakedmud-mod/lib/world/zones/examples/mproto/
nakedmud-mod/lib/world/zones/examples/oproto/
nakedmud-mod/lib/world/zones/examples/reset/
nakedmud-mod/lib/world/zones/examples/rproto/
nakedmud-mod/lib/world/zones/examples/trigger/
nakedmud-mod/lib/world/zones/limbo/
nakedmud-mod/lib/world/zones/limbo/room/
nakedmud-mod/lib/world/zones/limbo/rproto/
nakedmud-mod/src/alias/
nakedmud-mod/src/dyn_vars/
nakedmud-mod/src/editor/
nakedmud-mod/src/example_module/
nakedmud-mod/src/help2/
nakedmud-mod/src/set_val/
nakedmud-mod/src/socials/
nakedmud-mod/src/time/
#ifndef __MAP_H
#define __MAP_H
//*****************************************************************************
//
// map.h
//
// similar to a hashtable, but keys as well as values can be can be anything.
//
//*****************************************************************************

typedef struct map_data                   MAP;
typedef struct map_iterator               MAP_ITERATOR;

//
// if hash_func and/or compares are null, generic hashing and comparing
// functions are used.
//
// hash_func is expected to be a function that takes the key type used in
// this map, and returns a long value based on that key.
//
// compares is expected to be a function that takes two keys and compares
// them togher. If they are equal, 0 is returned. if key1 is less than key2,
// -1 is returned. otherwise, 1 is returned. If this function is NULL, a
// generic comparator is used that compares memory address of the two keys.
MAP     *newMap(void *hash_func, void *compares);
MAP *newMapSize(void *hash_func, void *compares, int size);
void  deleteMap(MAP *map);

int   mapPut    (MAP *map, const void *key, void *val);
void *mapGet    (MAP *map, const void *key);
void *mapRemove (MAP *map, const void *key);
int   mapIn     (MAP *map, const void *key);
int   mapSize   (MAP *map);


//*****************************************************************************
// map iterator function prototypes
//*****************************************************************************

// iterate across all of the elements in a map
#define ITERATE_MAP(key, val, it) \
  for(key = mapIteratorCurrentKey(it), val = mapIteratorCurrentVal(it); \
      key != NULL; \
      mapIteratorNext(it), \
      key = mapIteratorCurrentKey(it), val = mapIteratorCurrentVal(it))

MAP_ITERATOR *newMapIterator(MAP *map);
void          deleteMapIterator(MAP_ITERATOR *I);

void  mapIteratorReset            (MAP_ITERATOR *I);
void  mapIteratorNext             (MAP_ITERATOR *I);
void *mapIteratorCurrentVal       (MAP_ITERATOR *I);
const void *mapIteratorCurrentKey (MAP_ITERATOR *I);

#endif // __MAP_H