Linked list, I-Tree, Que, and Stack Library.

Copyright (c) 1990, 1997, Scott Beasley.
Released into the Public Domain

Scott Beasley.
704 Otis RD. Walterboro, SC 29488.
email - scottb@lowcountry.com


This file contains info for the linked list, que, and stack
functions.  A Simple test program has been written to give you 
an idea of how to use and call the functions, It's a spread sheet
like program to test various linked list functions.  We basicly 
build a 2d array with a linked list.  There's a simple interface
to add/change data in the elements and move around the list's.
This program does not go over all functions, but should give you
and idea, of how to use the library.

To compile the demo file lltest.c type:

   Unix:
   cc -ansi -o lltest lltest.c listque.c

   gcc:
   gcc -ansi -o lltest lltest.c listque.c

   Turbo/Borland:
   tcc lltest lltest.c listque.c
   bcc lltest lltest.c listque.c

   It should compile under any other ANSI C compiler.


To use the demo lltest, use the following one letter commands:

   M  - Start display, from Col, Row.
   W  - Change data in Col, Row. And start display from there.
   D  - Delete Col, Row.
   F  - Forward sort.
   R  - Reverse sort.
   Q  - Quit.


FUNCTIONS AND MACROS:

/*
   Macro that returns the number of entries in a link list.
*/
LLentrycount ( PLLHND llhnd );

/*
   Macro to set read write cursor to the first element.
*/
LLhomecursor ( PLLHND llhnd );

/*
   Return Pointer to current list element's storage data.
*/
LLreadcursor ( PLLHND llhnd );

/* 
   Returns NULL if end of list is reached.
*/
EOLL ( PLLHND llhnd );

/*
   Creates a link list for use.
*/
PLLHND LLcreate ( long entrysz, int bMemCpy, int style, COMPFUNC cmpfunc );

/*
   Delete a link list, and free up it's handle.
*/
int LLdestroy ( PLLHND llhnd );

/*
   Closes up a view to a linked list.
*/
int LLclose ( PLLHND llhnd );

/*
   Stores a entry in a given linked list.
   If ws == LLAPPEND then the entry is appened
   to the end of the list. Else it will insert
   it after pos position. If entry == NULL then
   a blank entry is allocated.
*/
int LLwrite ( PLLHND llhnd, LLELEMENT entry, int ws, int pos );

/*
   Reads a entry from a link list from pos if 
   rs == LLSEEK or at the current read postion 
   if rs == LLNEXT.
*/
int LLread ( PLLHND llhnd, LLELEMENT entry, int rs, int pos );

/*
   Deletes a entry from a link list.
*/
int LLdelete ( PLLHND llhnd, int pos );

/*
   Clears entry's from a link list.
*/
int LLclear ( PLLHND llhnd );

/*
   Set read write cursor to a certain element.
*/
int LLsetcursor ( PLLHND llhnd, int pos );

/*
   Set read write cursor to next element.
*/
int LLnext ( PLLHND llhnd );

/*
   Set read write cursor to prev element.
*/
int LLprev ( PLLHND llhnd );

/*
   Replace data in a element.
*/
int LLreplace ( PLLHND llhnd, int pos, LLELEMENT entry );

/*
   Search for a element in a list.
*/
int LLsearch ( PLLHND llhnd, COMPFUNC cmpfunc, LLELEMENT entry );

/*
   Search for a element in a sorted list.
*/
int LLbinsearch ( PLLHND llhnd, COMPFUNC cmpfunc, LLELEMENT entry );

/*
   Shell sort a list.
*/
int LLshellsort ( PLLHND llhnd, int istyle );

/*
   Macro that returns the number of entries in a queue.
*/
int Qentrycount ( PQHND qhnd );

/*
   Macro that checks for any queue entries.
*/
void Qempty ( PQHND qhnd );

/*
   Macro to reset que pointers
   to the top of the queue.
*/
void Qreset ( PQHND qhnd );

/*
   Create a queue for use.
*/
PQHND Qcreate ( int entrysz, int qsize );

/*
   Destroy a queue.
*/
int Qdestroy ( PQHND qhnd );

/*
   Place item in queue.
*/
int Qwrite ( PQHND qhnd, QELEMENT entry );

/*
   Get queue entry.
*/
int Qread ( PQHND qhnd, QELEMENT entry );

/*
   Macro to read queue entry without removeing it.
*/
int Qpeek ( PQHND qhnd, QELEMENT entry );

/*
   Create a stack for use.
*/
PSHND Screate ( int entrysz, int Stsize );

/*
   Destroy a stack.
*/
int Sdestroy ( PSHND shnd );

/*
   Push item onto stack.
*/
int Spush ( PSHND shnd, SELEMENT entry );

/*
   Pop next stack entry.
*/
int Spop ( PSHND shnd, SELEMENT entry );

/*
   Creates a I-Tree for use.
*/
PTHND Tcreate ( long entrysz, int bMemCpy, int style, COMPFUNC cmpfunc );

/*
   Creates a view into a I-Tree.
*/
PTHND Tdup ( PTHND thnd );

/*
   Delete a I-Tree, and free up it's handle.
*/
int Tdestroy ( PTHND thnd );

/*
   Writes to a I-Tree.
*/
int Twrite ( PTHND thnd, TELEMENT entry );

/*
   Finds a node in a I-Tree.
*/
TELEMENT Tsearch ( PTHND thnd, TELEMENT entry, TELEMENT retentry );

/*
   Deletes a node in a I-Tree.
*/
int Tdelete ( PTHND thnd, TELEMENT entry );

/*
   Closes up a view to a I-Tree.
*/
int Tclose ( PTHND thnd );
