nakedmudv3.3/
nakedmudv3.3/lib/
nakedmudv3.3/lib/logs/
nakedmudv3.3/lib/misc/
nakedmudv3.3/lib/players/
nakedmudv3.3/lib/txt/
nakedmudv3.3/lib/world/
nakedmudv3.3/lib/world/examples/
nakedmudv3.3/lib/world/examples/mproto/
nakedmudv3.3/lib/world/examples/oproto/
nakedmudv3.3/lib/world/examples/reset/
nakedmudv3.3/lib/world/examples/rproto/
nakedmudv3.3/lib/world/examples/trigger/
nakedmudv3.3/lib/world/limbo/
nakedmudv3.3/lib/world/limbo/room/
nakedmudv3.3/lib/world/limbo/rproto/
nakedmudv3.3/src/alias/
nakedmudv3.3/src/char_vars/
nakedmudv3.3/src/editor/
nakedmudv3.3/src/example_module/
nakedmudv3.3/src/help/
nakedmudv3.3/src/set_val/
nakedmudv3.3/src/socials/
nakedmudv3.3/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 an integer 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);
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