home *** CD-ROM | disk | FTP | other *** search
- '.so tmac.clman
- .TH "Intro"
- .IX Intro
- .SH NAME
- Intro - Introduction to the Generic Linked List.
- .SH DESCRIPTION
- The Generic Linked List package is a package to define, create, update,
- query and delete one or more (nodes of) linked lists, to sort linked
- lists, and so on. The user doesn't have to take care of allocating a
- number of bytes for a node, inserting on the right place, deleting and
- freeing a node and so on.
- .br
- Different kind of linked lists can be defined. In a \fIsingly\fP linked
- list each node points to the next node, in a \fIdoubly\fP linked list
- each node points also to the previous node. A \fIchain\fP is a list in
- which the last node has a NULL-pointer and in a \fIcircular\fP linked
- list the last node points back to the first node.
- .br
- The package consists of the following routines :
- .nf
- .if t .ta 0.2i 1.3i
- lDef define linked list
- lInfo get information about linked list
- lSort sort linked list
- lDel delete linked list
- lDelAll delete all linked lists
- lDump dump a linked list to a file
- lUndump undump a linked list from a file
- lInsNode insert node
- lInfoNode get information about node
- lGetNode get node
- lFndNode find node
- lFndFlagNode find node by flag
- lUpdNode update current node
- lDelNode delete node
- lInfoIndxNode get information about node by index
- lGetIndxNode get node by index
- lUpdIndxNode update node by index
- lDelIndxNode delete node by index
- .fi
- .SH ERROR CODES
- .if t .ta 0.2i 1.8i
- Here follows an enumeration of the possible error codes, and their
- meanings. For each function-call is specified which error codes
- could be expected. The marked errors (*) will also be written to
- the error-file \fI=listError=\fP.
- .nf
- lEMPTY_LIST linked list doesn't contain any nodes
- lEOL end of list reached
- lNO_LIST there are no linked lists defined (*)
- lNOT_DOUBLY backward searching / retrieving not possible for
- singly linked list (*)
- lNOT_FOUND node not found
- lOPEN_ERROR can't open linked list dump file for writing or
- reading (*)
- lSIZE_NE size of expected data and size of node are not
- equal (*)
- lUNKNOWN_FUNC function name is unknown (*)
- lUNKNOWN_ID list identifier is unknown (*)
- lWRONG_CC parameter \fIcc\fP has wrong value (*)
- lWRONG_INDEX index out of range (*)
- lWRONG_ORDER parameter \fIorder\fP has wrong value (*)
- lWRONG_SD parameter \fIsd\fP has wrong value (*)
- lWRONG_THEORY parameter \fItheory\fP has wrong value (*)
- lWRONG_WHERE parameter \fIwhere\fP has wrong value (*)
- lWRONG_WHICH parameter \fIwhich\fP has wrong value (*)
- .fi
- .SH LIBRARY
- $(TOOLS_HOME)/Lib/list.a
- .SH INCLUDE FILE
- $(TOOLS_HOME)/List/list.h
- .SH PORTABILITY
- The Generic Linked List package is a very portable tool. The tool is
- developed on UNIX and ported to MSDOS, VAX-VMS and Macintosh. On
- those 'ported' machines the library isn't created, but list.c and list.h
- were treated the same as all the other source-files (*.[ch]) of the
- program, which used the Generic Linked List package.
- .SH EXAMPLE
- .if t .ta 0.3i 0.6i 0.9i 1.2i 2.2i 3.2i 4.2i 4.5i 4.8i
- .nf
- #include <stdio.h>
- #include "list.h"
-
- typedef struct rapport {
- char title[30];
- char author[15];
- int date;
- } Rapport;
- int rapSz = sizeof(Rapport);
-
- static void insRap(), prRapAll(), prRap();
- static int search(), compare();
-
- main()
- {
- int id, code, search_date;
- Rapport rap;
-
- id = lDef(lSINGLY, lCHAIN);
-
- insRap(id, lFIRST, 1, "Book 1", "People", 890129);
- insRap(id, lFIRST, 2, "Book 2", "More People", 890130);
- insRap(id, lLAST, 1, "Book 3", "Lots of People", 890131);
-
- fprintf(stdout, "lGetNode\n");
- prRapAll(id);
-
- fprintf(stdout, "lGetIndxNode\n");
- code = lGetIndxNode(id, 4, &rap, rapSz);
- prRap(code, &rap);
- code = lGetIndxNode(id, 2, &rap, rapSz);
- prRap(code, &rap);
- code = lGetIndxNode(id, -1, &rap, rapSz);
- prRap(code, &rap);
- code = lGetIndxNode(id, 3, &rap, rapSz);
- prRap(code, &rap);
-
- fprintf(stdout, "lFndNode\n");
- search_date = 890129;
- code = lFndNode(id, lFIRST, search, &search_date, &rap, rapSz);
- prRap(code, &rap);
- code = lFndNode(id, lNEXT, search, &search_date, &rap, rapSz);
- prRap(code, &rap);
- code = lFndNode(id, lNEXT, search, &search_date, &rap, rapSz);
- prRap(code, &rap);
-
- code = lDump(id, "dump");
- fprintf(stdout, "lDump : %d\n", code);
-
- lDel(id);
-
- id = lUndump("dump");
- fprintf(stdout, "lUndump : %d\n", id);
-
- insRap(id, lFIRST, 4, "Book 4", "The Author", 891127);
-
- prRapAll(id);
-
- fprintf(stdout, "lFndFlagNode\n");
- code = lFndFlagNode(id, lFIRST, 1, &rap, rapSz);
- prRap(code, &rap);
- code = lFndFlagNode(id, lNEXT, 1, &rap, rapSz);
- prRap(code, &rap);
- code = lFndFlagNode(id, lFIRST, 2, &rap, rapSz);
- prRap(code, &rap);
- code = lFndFlagNode(id, lFIRST, 7, &rap, rapSz);
- prRap(code, &rap);
-
- fprintf(stdout, "Untouched list\n");
- prRapAll(id);
-
- fprintf(stdout, "lSort\n");
- lSort(id, lDESCENDING, lBUBBLE, compare);
- prRapAll(id);
-
- fprintf(stdout, "lSort\n");
- lSort(id, lASCENDING, lHEAP, compare);
- prRapAll(id);
-
- lDelAll();
- }
-
- static void
- insRap(id, where, flag, title, author, date)
- int id, where, flag, date;
- char *title, *author;
- {
- int code;
- Rapport rap;
-
- strcpy(rap.title, title);
- strcpy(rap.author, author);
- rap.date = date;
- code = lInsNode(id, where, &rap, rapSz, flag);
- }
-
- static void
- prRapAll(id)
- int id;
- {
- int code;
- Rapport rap;
-
- code = lGetNode(id, lFIRST, &rap, rapSz);
- prRap(code, &rap);
- while (code == lFIRST || code == lSUCCESS || code == lLAST) {
- code = lGetNode(id, lNEXT, &rap, rapSz);
- prRap(code, &rap);
- }
- }
-
- static void
- prRap(code, rpprt)
- int code;
- Rapport *rpprt;
- {
- if (code >= 0)
- fprintf(stdout, "Rapport : '%s' '%s' '%d'\n", rpprt->title,
- rpprt->author, rpprt->date);
- else
- fprintf(stdout, "Return code = %d\n", code);
- }
-
- static int
- search(date, rpprt)
- int *date;
- Rapport *rpprt;
- {
- if (rpprt->date > *date)
- return(lFOUND);
- else
- return(lNOT_FOUND);
- }
-
- static int
- compare(data1, data2)
- Rapport *data1, *data2;
- {
- int k = strcmp(data1->author, data2->author);
-
- if (k == 0)
- return(lSAME); /* key1 == key2 */
- else if (k > 0)
- return(l2LT1); /* key1 > key2 */
- else if (k < 0)
- return(l1LT2); /* key1 < key2 */
- }
- .fi
- .sp 2
- This example program produces the following output :
- .nf
- lGetNode
- Rapport : 'Book 2' 'More People' '890130'
- Rapport : 'Book 1' 'People' '890129'
- Rapport : 'Book 3' 'Lots of People' '890131'
- Return code = -9
- lGetIndxNode
- Return code = -13
- Rapport : 'Book 1' 'People' '890129'
- Return code = -13
- Rapport : 'Book 3' 'Lots of People' '890131'
- lFndNode
- Rapport : 'Book 2' 'More People' '890130'
- Rapport : 'Book 3' 'Lots of People' '890131'
- Return code = -10
- lDump : 0
- lUndump : 1
- Rapport : 'Book 4' 'The Author' '891127'
- Rapport : 'Book 2' 'More People' '890130'
- Rapport : 'Book 1' 'People' '890129'
- Rapport : 'Book 3' 'Lots of People' '890131'
- Return code = -9
- lFndFlagNode
- Rapport : 'Book 1' 'People' '890129'
- Rapport : 'Book 3' 'Lots of People' '890131'
- Rapport : 'Book 2' 'More People' '890130'
- Return code = -10
- Untouched list
- Rapport : 'Book 4' 'The Author' '891127'
- Rapport : 'Book 2' 'More People' '890130'
- Rapport : 'Book 1' 'People' '890129'
- Rapport : 'Book 3' 'Lots of People' '890131'
- Return code = -9
- lSort
- Rapport : 'Book 4' 'The Author' '891127'
- Rapport : 'Book 1' 'People' '890129'
- Rapport : 'Book 2' 'More People' '890130'
- Rapport : 'Book 3' 'Lots of People' '890131'
- Return code = -9
- lSort
- Rapport : 'Book 3' 'Lots of People' '890131'
- Rapport : 'Book 2' 'More People' '890130'
- Rapport : 'Book 1' 'People' '890129'
- Rapport : 'Book 4' 'The Author' '891127'
- Return code = -9
- .fi
- .SH VERSION
- Generic Linked List 0.8, March 1993.
- .SH PUBLIC DOMAIN
- The Generic Linked List package is in the public domain. If you have
- any comments, suggestions, or find any bugs, or make any changes you'd
- like to share, please let et e┬ow.
- .SH AUTHOR
- Copyright (c) 1993 by Anita Eijs (anita@bouw.tno.nl).
- .sp 1
- .nf
- TNO - Bouw - BouwInformatica
- P.O. Box 49
- 2600 AA Delft
- The Netherlands
- .fi
-