Ilist alist2_insert(Ilist p, int key, int a, int b);This is a quick and clean alist2 (association list) for pairs of integers. Insert key/
Ilist alist2_remove(Ilist p, int key);
Ilist alist_insert(Ilist p, int key, int val);This is a quick and clean alist (association list) for integers. Insert key/value pairs. With assoc(key), retreive value. If an key has more than one value, the most recent is returned. It an key is not in the alist, INT_MIN is returned. An alist can be freed with zap_ilist(alist).
int assoc(Ilist p, int key);See alist_insert.
int assoc2a(Ilist p, int key);See alist2_insert.
int assoc2b(Ilist p, int key);See alist2_insert.
Ilist copy_ilist(Ilist p);This routine copies a Ilist (the whole list) and returns the copy.
Plist copy_plist(Plist p);This routine copies a Plist (the whole list) and returns the copy.
void fprint_glist_mem(FILE *fp, BOOL heading);This routine prints (to FILE *fp) memory usage statistics for data types associated with the glist package. The Boolean argument heading tells whether to print a heading on the table.
void fprint_ilist(FILE *fp, Ilist p);The list of integers is printed to FILE *fp like this: (4 5 1 3), without a newline.
void free_ilist(Ilist p);
void free_mlist(Mlist p);
void free_plist(Plist p);
Ilist get_ilist(void);
Mlist get_mlist(void);
Plist get_plist(void);
Ilist ilist_append(Ilist lst, int i);This routine appends an integer to a Ilist. The updated Ilist is returned.
Ilist ilist_cat(Ilist p1, Ilist p2);Concatenate two Ilists and return the result. The result is constructed from the arguments, so do not refer to either of the arguments after the call.
That is, both arguments are "used up".
Ilist ilist_cat2(Ilist p1, Ilist p2);Concatenate two Ilists and return the result. In this version, the second ilist is copied and placed at the end of p1. That is, p1 is "used up", but p2 is not.
Ilist ilist_copy(Ilist p);
int ilist_count(Ilist p);This routine returns the length of a Ilist.
Ilist ilist_insert_up(Ilist p, int i);
Ilist ilist_intersect(Ilist p1, Ilist p2);Construct the intersection (as a new Ilist).
The arguments are not changed.
BOOL ilist_is_set(Ilist a);
BOOL ilist_member(Ilist lst, int i);This function checks if an integer is a member of a Ilist. (If a node in the Ilist contains a pointer instead of an integer, the result is undefined.)
int ilist_occurrences(Ilist p, int i);How many times does an integer occur in an ilist?
Ilist ilist_pop(Ilist p);This routine takes a nonempty Ilist, removes and frees the first node (ignoring the contents), and returns the remainder of the list.
Ilist ilist_prepend(Ilist lst, int i);This routine inserts an integer as the first member of a Ilist. The updated Ilist is returned.
Ilist ilist_rem_dups(Ilist m);Take a list of integers and remove duplicates.
This version "uses up" the argument.
Ilist ilist_remove_last(Ilist p);
Ilist ilist_removeall(Ilist p, int i);Remove all occurrences of i.
Ilist ilist_set(Ilist m);Take a list of integers and remove duplicates. This creates a new list and leave the old list as it was. Don't make any assumptions about the order of the result.
BOOL ilist_subset(Ilist a, Ilist b);
Ilist ilist_subtract(Ilist p1, Ilist p2);Return the members of p1 that are not in p2.
The arguments are not changed.
Mlist mlist_member(Mlist lst, int i);
BOOL mlist_multimember(Mlist lst, int i, int n);
BOOL mlist_multisubset(Mlist a, Mlist b);
Mlist mlist_removeall(Mlist p, int i);Remove all occurrences of i.
Mlist multiset_add(Mlist p, int i);
Mlist multiset_add_n(Mlist p, int i, int n);
int multiset_occurrences(Mlist m, int i);
Ilist multiset_to_set(Mlist m);
Mlist multiset_union(Mlist a, Mlist b);The result is constructed from the arguments, so do not refer to either of the arguments after the call.
That is, both arguments are "used up".
void p_glist_mem();This routine prints (to stdout) memory usage statistics for data types associated with the glist package.
void p_ilist(Ilist p);The list of integers is printed to stdout like this: (4 5 1 3), with a '\n' at the end.
void p_mlist(Mlist p);The list of integers is printed to stdout like this: (4 5 1 3), with a '\n' at the end.
Plist plist_append(Plist lst, void *v);This routine appends a pointer to a Plist. The updated Plist is returned.
Plist plist_cat(Plist p1, Plist p2);Concatenate two Plists and return the result. The result is constructed from the arguments, so do not refer to either of the arguments after the call.
That is, both args are destroyed.
Plist plist_cat2(Plist p1, Plist p2);Concatenate two Plists and return the result. In this version, the second plist is copied and placed at the end of p1.
That is, the first arg is destroyed, and the second is preserved.
int plist_count(Plist p);This routine returns the length of a Plist.
BOOL plist_member(Plist lst, void *v);This function checks if a pointer is a member of a Plist.
Plist plist_pop(Plist p);This routine takes a nonempty Plist, removes and frees the first node (ignoring the contents), and returns the remainder of the list.
Plist plist_prepend(Plist lst, void *v);This routine inserts a pointer as the first member of a Plist. The updated Plist is returned.
Plist plist_remove(Plist p, void *v);Remove the first occurrence of a pointer from a Plist.
Plist plist_remove_last(Plist p);
BOOL plist_subset(Plist a, Plist b);
Plist plist_subtract(Plist p1, Plist p2);Return the members of p1 that are not in p2.
The arguments are not changed.
Ilist reverse_ilist(Ilist p);This routine reverses a Ilist. The list is reversed in-place, so you should not refer to the argument after calling this routine. A good way to use it is like this:
p = reverse_ilist(p);
Plist reverse_plist(Plist p);This routine reverses a Plist. The list is reversed in-place, so you should not refer to the argument after calling this routine. A good way to use it is like this:
p = reverse_plist(p);
Plist sort_plist(Plist objects, Ordertype (*comp_proc) (void *, void *));
void zap_ilist(Ilist p);This routine frees a Ilist (the whole list).
void zap_mlist(Mlist p);This routine frees a Plist (the whole list). The things to which the members point are not freed.
void zap_plist(Plist p);This routine frees a Plist (the whole list). The things to which the members point are not freed.
typedef struct plist * Plist; struct plist { void *v; Plist next; }; typedef struct ilist * Ilist; struct ilist { int i; Ilist next; }; typedef struct mlist * Mlist; struct mlist { int i; int n; Mlist next; };
These activities are projects of the Mathematics and Computer Science Division of Argonne National Laboratory.