list - /* * list.h */ #include "node.h" typedef...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* * list.h */ #include "node.h" typedef struct { int count; node_t *pos; node_t *first; node_t *last; int (*compare) (void *arg1, void *arg2); } list_t; list_t *createList(int (*compare) (void *arg1, void *arg2)); /* * - creates and initialises a new empty list * * compare is a pointer to a comparison function which compares two "key" * values contained within the data structures referenced by arg1 and * arg2, respectively. The function itself will return a strictly * positive integer value (>0) if the first key value is greater than * the second; a strictly negative (<0) integer value if the first is * less than the second and an integer value of zero (0) if they are * determined within the function to be equal. The function's primary * use is to facilitate searches within the list. * * return: a pointer to the newly created and initialised list head node * which represents an empty list, or NULL if the creation fails. */ static int insert(list_t *list, node_t *predPtr, void *data); /* * - inserts a new node which contains a reference to the data argument * in the list after the node referenced by predPtr. If predptr is NULL * the new node is inserted at the front of the list. * * list is a pointer to a properly initialised list head node (through a * previous call of createList()) referencing the list within which * the new node is to be inserted * * data is a pointer to the data to be associated with the new node to be * inserted in the list * * postcondition: the list contains a new node referencing the data argument, * increasing by one the number of nodes stored in the list * * return: true if the insertion was successful, and false if not (due to list * overflow). */ int insertFirst(list_t *list, void *data); /* * - inserts a new node which contains a reference to the data argument * in the front of the list * * list is a pointer to a properly initialised list head node (through a * previous call of createList()) referencing the list atop which * the new node is to be pushed * * data is a pointer to the data to be associated with the new node to be * inserted at the front of the list * * postcondition: the list contains a new node (at the front) referencing the * data argument, increasing by one the number of nodes stored * in the list * * return: true if the insertion was successful, and false if not (due to list * overflow). */ int insertLast(list_t *list, void *data); /* * - inserts a new node which contains a reference to the data argument * at the end of the list * * list is a pointer to a properly initialised list head node (through a * previous call of createList()) referencing the list at the end of * which the new node is to be inserted * * data is a pointer to the data to be associated with the new node to be * inserted at the end of the list * * postcondition: the list contains a new node (at the end) referencing the * data argument, increasing by one the number of nodes stored * in the list * * return: true if the insertion was successful, and false if not (due to list...
View Full Document

This note was uploaded on 01/17/2012 for the course CSC 1254 taught by Professor Blanks,l during the Fall '08 term at LSU.

Page1 / 9

list - /* * list.h */ #include "node.h" typedef...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online