/Users/bernard/b20/bsoft/include/linked_list.h(3)

NAME
/Users/bernard/b20/bsoft/include/linked_list.h - Header file for generalized linked list functions.

SYNOPSIS

#include <stdlib.h>
#include <string.h>

  Functions
char * add_item (char **list, unsigned long size)
Adds an item to a linked list.
char * append_item (char **list, char *item)
Appends an item to a linked list.
char * copy_item (char *toitem, char *fromitem, unsigned long size)
Copies an item to an existing item without changing the link.
char * remove_item (char **list, char *item, unsigned long size)
Finds the given item and deletes it from the linked list.
char * replace_item (char **list, char *item, char *new_item)
Finds the given item and replaces it with the new item.
char * copy_list (char *list, unsigned long size)
Generates a complete copy of a linked list.
long kill_list (char *list, unsigned long size)
Frees all the items in a linked list.
long count_list (char *list)
Counts the number of items in a linked list.
long reverse_list (char **list)
Reverse the order of items in a linked list.

Detailed Description

Header file for generalized linked list functions.

Author:
    Bernard Heymann

Date:
    Created: 20031203

    Modified: 20150206

Definition in file linked_list.h.

Function Documentation

  char* add_item (char ** list, unsigned long size)

Adds an item to a linked list.

Parameters:
    **list pointer to first item in the list.
    size size of item.

Returns:
    char* new item.

    If the list is not defined, the new item becomes the first in the list.
    Otherwise, the list is traversed to find the end and the new item appended.
    Any structure with a pointer to itself as a first element can be used in a
    linked list. However, a linked list can only consist of one type of structure.

Definition at line 26 of file linked_list.cpp.

  char* append_item (char ** list, char * item)

Appends an item to a linked list.

Parameters:
    **list pointer to first item in the list.
    *item item to append.

Returns:
    char* item.

    If the list is not defined, the new item becomes the first in the list.
    Otherwise, the list is traversed to find the end and the new item appended.
    Any structure with a pointer to itself as a first element can be used in a
    linked list. However, a linked list can only consist of one type of structure.

Definition at line 59 of file linked_list.cpp.

  char* copy_item (char * toitem, char * fromitem, unsigned long size)

Copies an item to an existing item without changing the link.

Parameters:
    *toitem item to copy to.
    *fromitem item to copy from.
    size size of item.

Returns:
    char* the resultant item.

    The items must be the same type.

Definition at line 87 of file linked_list.cpp.

  char* copy_list (char * list, unsigned long size)

Generates a complete copy of a linked list.

Parameters:
    *list linked list.
    size size of list item.

Returns:
    char* new list.

Definition at line 185 of file linked_list.cpp.

  long count_list (char * list)

Counts the number of items in a linked list.

Parameters:
    *list first item in the linked list.

Returns:
    long number of items in the list.

Definition at line 235 of file linked_list.cpp.

  long kill_list (char * list, unsigned long size)

Frees all the items in a linked list.

Parameters:
    *list first item in the linked list.
    size size of item.

Returns:
    long number of items deallocated.

    The list is traversed, setting a pointer to the next item before
    deallocating the current item.

Definition at line 214 of file linked_list.cpp.

  char* remove_item (char ** list, char * item, unsigned long size)

Finds the given item and deletes it from the linked list.

Parameters:
    **list pointer to first item in the linked list.
    *item item to be deleted.
    size size of item.

Returns:
    char* item after the one removed.

    If the item is the first in the list, the list pointer is set to point
    to the next item.
    Otherwise, the list is traversed to find the item, the previous item's
    pointer is set to the next item, and the current item deallocated.

Definition at line 114 of file linked_list.cpp.

  char* replace_item (char ** list, char * item, char * new_item)

Finds the given item and replaces it with the new item.

Parameters:
    **list pointer to first item in the linked list.
    *item item to be replaced.
    *new_item new item.

Returns:
    char* new item.

    If the item is the first in the list, the list pointer is set to point
    to the new item.
    Otherwise, the list is traversed to find the item, the previous item's
    pointer is set to the new item, the new item's pointer is set to that
    of the old item, and the old item is deallocated.

Definition at line 152 of file linked_list.cpp.

  long reverse_list (char ** list)

Reverse the order of items in a linked list.

Parameters:
    *list first item in the linked list.

Returns:
    long number of items in the list.

Definition at line 252 of file linked_list.cpp.

Author

Generated automatically by Doxygen for Bsoft from the source code.