list_util - List Manipulation Utilities

The list manipulation utilities are a set of general purpose functions used to build and access lists of items. For example, the following fragment of code (i) inputs and save N lines from standard input, (ii) displays the N saved lines, and (iii) deletes the saved text:

    #include  <stdio.h>				-- Standard I/O definitions.
    #include  "list_util.h"			-- List manipulation functions.
    #include  "str_util.h"			-- String manipulation functions.
    char  buffer[MAXINPUT], *s ;
    List  list = NULL ;

    while (s = gets (buffer))			-- Input and save text.
        listAdd (&list, -1, (void *) str_dupl (s, -1)) ;

    for (i = 1 ;  s = (char *) listGet (list, i) ;  i++)
        printf ("Line %d: %s\n", i, s) ;	-- Display text.

    while (listDelete (&list, 1) != NULL)
        ;					-- Delete text.

Public Procedures

listAdd() - adds an item to a list.
listDelete() - deletes an item from a list.
listFind() - finds an item in a list.
listGet() - retrieves the value of an item from a list.
listLength() - returns the number of items in a list.

Source Files


(See libgpl for the complete source, including support routines and build files.)

Alex Measday  /  E-mail