/*************************** hashing-bool-ops.h ***************************** Purpose: External declarations for boolean operations implemented using hashing. Provenance: Written and tested by S. Wartik, April 1991. Notes: None. **/ #ifndef TRUE # define TRUE 1 # define FALSE 0 typedef int boolean; #endif typedef int elementType; /* This could be any valid type. */ typedef struct be_str { /* A link in the chain from a bucket. */ elementType datum; /* Implemented as a linked list. */ struct be_str *next_datum; } bucket_element; typedef struct { /* A hashing-based set implementation. */ int Number_Of_Buckets; bucket_element **buckets; int (*hashing_function)(); /* The set's hashing function. */ boolean (*comparator)(); /* A tester for element equality. */ } set; #ifdef __STDC__ extern void Create(int Number_Of_Buckets, int (*Hashing_Function)(), boolean (*Comparator)(), set *s); extern void Clear(set *s); extern void Insert(set *s, elementType e); extern void Delete(set *s, elementType e); extern void Unite(set *s1, set *s2, set *s3); extern void Intersect(set *s1, set *s2, set *s3); extern void Subtract(set *s1, set *s2, set *s3); extern boolean Empty(set *s); extern boolean Member(set *s, elementType e); extern void Copy(set *source, set *destination); extern void Iterate(set *s, boolean (*f)()); boolean Error_Occurred(); #else extern void Create(); /* Create a set. */ extern void Clear(); /* Make a set contain zero elements. */ extern void Insert(); /* Insert an element into a set. */ extern void Delete(); /* Remove an element from a set. */ extern void Unite(); /* Form the union of two sets. */ extern void Intersect(); /* Form the intersection of two sets. */ extern void Subtract(); /* Form the difference of two sets. */ extern boolean Empty(); /* Return TRUE iff a set has zero elements. */ extern boolean Member(); /* Return TRUE iff a specified value is */ /* a member of a set. */ extern void Copy(); /* Make a copy of a set. */ extern void Iterate(); /* Invoke a function on every element * /* in a set. */ extern boolean Error_Occurred(); /* Return TRUE iff the last */ /* operation caused an error. */ #endif