void destroy_discrim_tree(Discrim d);This routine frees all the memory associated with a discrimination index. It can be used with either wild or tame trees.
void discrim_dealloc(Discrim d);This routine frees an empty discrimination index (wild or tame).
BOOL discrim_empty(Discrim d);This Boolean function checks if a discrimination index is empty. It can be used with either wild or tame trees.
Discrim discrim_init(void);This routine allocates and returns an empty discrimination index. It can be used for either wild or tame indexing.
void discrim_tame_cancel(Discrim_pos pos);This routine must be called if you get some, but not all answers to a tame discrimintaion query. The Context (which was given to the discrim_tame_retrieve_first() call) is cleared, and the memory associated the retrieval state is freed.
void *discrim_tame_retrieve_first(Term t, Discrim root, Context subst, Discrim_pos *ppos);This routine, along with discrim_tame_retrieve_next(), gets answers from a tame discrimination index. This routine retrieves the first object associated with a term, say ft, more general than Term t. (NULL is returned if there is none.) The substitution for variables of ft is placed into Context subst.
If an object is returned, Discrim_pos *ppos is set to the retrieval state and is used for subsequent discrim_tame_retrieve_next() calls.
If you to get some, but not all answers, you must call discrim_tame_cancel() to clear the substitution and free memory associated with the Discrim_pos.
void *discrim_tame_retrieve_next(Discrim_pos pos);This routine retrieves the next object in the sequence of answers to a query of a tame discrimination tree. You must not explicitly clear the Context you gave to discrim_tame_retrieve_first()---that is handled internally. See discrim_tame_retrieve_first().
void discrim_tame_update(Term t, Discrim root, void *object, Indexop op);This routine inserts (op==INSERT) or deletes (op==DELETE) an object into/from a tame discrimination index. Term t is the key, root is the root of the discrimination tree, and *object is a pointer (in many cases, *object will be t). See discrim_tame_retrieve_first().
A fatal error occurs if yout ry to delete an object that was not previouly inserted.
void discrim_wild_cancel(Discrim_pos pos);This routine should be called if you get some, but not all answers to a wild discrimintaion query. The memory associated the retrieval state is freed.
void *discrim_wild_retrieve_first(Term t, Discrim root, Discrim_pos *ppos);This routine, along with discrim_wild_retrieve_next(), gets answers from a wild discrimination index. This routine retrieves the first object associated with a term more general than Term t. (NULL is returned if there is none.)
If an object is returned, Discrim_pos *ppos is set to the retrieval state and is used for subsequent discrim_tame_retrieve_next() calls.
If you to get some, but not all answers, you must call discrim_wild_cancel() to clear the substitution and free memory associated with the Discrim_pos.
void *discrim_wild_retrieve_next(Discrim_pos pos);This routine retrieves the next object in the sequence of answers to a query of a wild discrimination tree. See discrim_wild_retrieve_first().
void discrim_wild_update(Term t, Discrim root, void *object, Indexop op);This routine inserts (op==INSERT) or deletes (op==DELETE) an object into/from a wild discrimination index. Term t is the key, root is the root of the discrimination tree, and *object is a pointer (in many cases, *object will be t). See discrim_tame_retrieve_first().
A fatal error occurs if yout ry to delete an object that was not previouly inserted.
void fprint_discrim_mem(FILE *fp, BOOL heading);This routine prints (to FILE *fp) memory usage statistics for several types of node associated with discrimination indexing. The Boolean argument heading tells whether to print a heading on the table.
void fprint_discrim_tame_index(FILE *fp, Discrim d);This routine prints (to FILE *fp) a tame discrimination index.
void fprint_discrim_wild_index(FILE *fp, Discrim d);This routine prints (to FILE *fp) a wild discrimination index.
void p_discrim_mem(void);This routine prints (to stdout) memory usage statistics for several types of node associated with discrimination indexing.
void p_discrim_tame_index(Discrim d);This routine prints (to stdout) a tame discrimination index.
void p_discrim_wild_index(Discrim d);This routine prints (to stdout) a wild discrimination index.
typedef struct discrim * Discrim; typedef struct discrim_pos * Discrim_pos;
The "wild" kind is an imperfect filter, and it does not bind variables. The caller must also call a routine, say match(), to check if the answers are really more general than the query term and to construct the substitution. Wild indexing supports associative-commutative (AC) and commutative/symmetric (C) symbols. Indexing terms with AC symbols works by considering the number of arguments and the number of nonvariable arguments of AC terms that do not occur in other AC terms. (The term "wild" is used because all variables in the discrimination tree are treated as the the wildcard symbol *).
With the "tame" kind, every answer is more general than the query term, and the matching substitution is constructed during the retrieval. Wild indexing supports commutative/summetric (C) symbols, but it does not support associative-commutative (AC) symbols. Retrieval with C symbols can produce duplicate answers. (The term "tame" is used because the indexing is not wild.)
Note that some of the routines in this package (the ones without "wild" or "tame" in their names) are used with either wild or tame indexing.
There is probably a higher-level package (mindex ?) which provides a uniform interface to these and other indexing methods.
These activities are projects of the Mathematics and Computer Science Division of Argonne National Laboratory.