home *** CD-ROM | disk | FTP | other *** search
- /* > H.Map - Map data type header file */
-
- #ifndef __map_h
-
- #define __map_h
-
- struct link
- {
- struct link *next;
- char data[1];
- };
-
- typedef struct link *link;
-
- struct map
- {
- link *bucket; /* array of bucket links */
- int (*hash)(const void *); /* hash function: domain -> int */
- int buckets; /* number of buckets in hash table */
- int domain_size; /* size of one element in domain */
- int range_size; /* size of one element in range */
- };
-
- typedef struct map *map;
-
- /* General component routines */
-
- map map_new (int domain_len, int range_len, int buckets, int (*hash)(const void *));
- void map_free (map m);
- void map_clear (map m);
- int map_copy (map m1, const map m2);
- int map_equal (const map m1, const map m2);
- int map_empty (const map m);
- int map_size (const map m);
-
- /* Iterator */
-
- #define STATUS_CONTINUE 0 /* Continue processing */
- #define STATUS_STOP 1 /* Stop processing */
- #define STATUS_ERROR (-1) /* Error - terminate */
-
- int map_iterate (const map m, int (*process)(void *, void *));
-
- /* Map-specific routines */
-
- int map_bind (map m, const void *domain_val, const void *range_val);
- int map_unbind (map m, const void *domain_val);
- void *map_value (const map m, const void *domain_val);
- int map_bound (const map m, const void *domain_val);
-
- #endif
-