Main Page | Class List | File List | Class Members | File Members

list.h

00001 /*
00002  * Copyright 2003, 2004 Ian Searle. All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following
00006  * conditions are met:  
00007  *
00008  * 1: Redistributions of source code must retain the above
00009  * copyright notice, this list of conditions and the following
00010  * disclaimer. 
00011  *
00012  * 2: Redistributions in binary form must reproduce the above
00013  * copyright notice, this list of conditions and the following
00014  * disclaimer in the documentation and/or other materials
00015  * provided with the distribution. 
00016  *
00017  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY  EXPRESS OR IMPLIED
00018  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020  * DISCLAIMED. IN NO EVENT SHALL IAN SEARLE OR CONTRIBUTORS
00021  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
00022  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00023  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00024  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00025  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00027  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00028  * DAMAGE. 
00029  *
00030  */
00031 
00032 #ifndef  LIST_H
00033 #define  LIST_H
00034 
00035 #include "listnode.h"
00036 #include <stdio.h>
00037 
00039 typedef struct _list List;
00040 
00042 struct _list
00043 {
00044   int numNodes;                 
00045   ListNode *firstNode;          
00046   ListNode *lastNode;           
00047 };
00048 
00049 void list_Init(void *(*list_allocate)(size_t), void (*list_deallocate)(void *));
00050 
00051 extern List *list_Create (void);
00052 extern void list_Destroy (List *);
00053 extern void list_DestroyAllNodes (List *);
00054 extern int list_DestroyNodeByPos (List *, int);
00055 extern int list_DestroyNodeByAddr (List *, ListNode *);
00056 extern List *list_Copy (List *list, void *(*copy)(void *));
00057 
00058 extern ListNode *list_InsertNode (List *, ListNode *, int);
00059 
00060 extern ListNode *list_EnqueueNode (List *, ListNode *);
00061 extern ListNode *list_DequeueNode (List *);
00062 
00063 extern ListNode *list_PushNode (List *, ListNode *);
00064 extern ListNode *list_PopNode (List *);
00065 
00066 extern ListNode *list_DetachNodeByPos (List *, int);
00067 extern ListNode *list_DetachNodeByAddr (List *, ListNode *);
00068 
00069 extern ListNode *list_GetNodeByPos (List *, int);
00070 extern void *list_GetNodeDataByPos (List *, int);
00071 
00072 extern void list_PrintToFile (List *, FILE *);
00073 extern int list_IsPosValid (List *, int);
00074 
00075 extern ListNode *list_GetLastNode (List *);
00076 extern ListNode *list_GetFirstNode (List *);
00077 
00078 #define list_GetNumNodes(list)  (((List *)(list))->numNodes)
00079 
00080 #endif /* LIST_H */

Generated on Wed Feb 25 23:01:10 2004 by doxygen 1.3.4