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 Ilists and Plists. 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);This routine frees a Ilist node. If you wish to free a whole Ilist list, call zap_ilist();
void free_plist(Plist p);This routine frees a Plist node. If you wish to free a whole Plist list, call zap_plist();
Ilist get_ilist(void);This routine allocates and returns a Ilist node.
Plist get_plist(void);This routine allocates and returns a Plist node.
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 not refer to either of the arguments after the call.
Ilist ilist_copy(Ilist p);
int ilist_count(Ilist p);This routine returns the length of a Ilist.
Ilist ilist_intersect(Ilist p1, Ilist p2);
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.)
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_subtract(Ilist p1, Ilist p2);Return the members of p1 that are not in p2;
void p_glist_mem(void);This routine prints (to stdout) memory usage statistics for Ilists and Plists.
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.
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.
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.
BOOL plist_subset(Plist a, Plist b);
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);
void zap_ilist(Ilist p);This routine frees a Ilist (the whole list). If the list contains any pointers, the things to which they 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 glist * Glist; struct glist { Glist next; union { int i; void *v; } u; }; typedef struct plist * Plist; struct plist { void *v; Plist next; }; typedef struct ilist * Ilist; struct ilist { int i; Ilist next; };
Note that when assigning to and from a (void *), you don't need a cast, but when dereferencing a (void *), you do need a cast.
There are two informal subtypes: "ilist" for lists of integers, and "plist" for lists of pointers. Several of the routines (which have "ilist" or "plist" in the name) apply to these suptypes. The rest of the routines apply to any Glist.
These activities are projects of the Mathematics and Computer Science Division of Argonne National Laboratory.