Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

sflsq.h

Go to the documentation of this file.
00001 /*
00002 *  sfxlist.h
00003 *
00004 *  Special LIST uses a memcap and splays nodes based on access
00005 *
00006 *  All of these functions are based on lists, which use
00007 *  the standard malloc.
00008 *
00009 *  Note that NODE_DATA can be redifined with the
00010 *  define below.
00011 *
00012 */
00013 #ifndef _SFLSQ_
00014 #define _SFLSQ_
00015 
00016 /*
00017 *  
00018 */
00019 typedef void * NODE_DATA;
00020 
00021 /*
00022 *    Simple list,stack or queue NODE
00023 */ 
00024 typedef struct sf_lnode
00025 {
00026   struct sf_lnode *next;
00027   struct sf_lnode *prev;
00028   NODE_DATA      ndata;
00029 }
00030 SF_QNODE,SF_SNODE,SF_LNODE;
00031 
00032 
00033 /*
00034 *       Integer Stack - uses an array from the subroutines stack
00035 */
00036 typedef struct {
00037  unsigned *stack;
00038  int nstack;
00039  int n;
00040  int imalloc;
00041 }
00042 SF_ISTACK;
00043 /*
00044 *       Pointer Stack - uses an array from the subroutines stack
00045 */
00046 typedef struct {
00047  void **stack;
00048  int nstack;
00049  int n;
00050  int imalloc;
00051 }
00052 SF_PSTACK;
00053 
00054 
00055 /*
00056 *  Simple Structure for Queue's, stacks, lists
00057 */ 
00058 typedef struct sf_list
00059 {
00060   SF_LNODE *head, *tail;  
00061   SF_LNODE *cur;  /* used for First/Next walking */
00062   int       count;
00063 }
00064 SF_QUEUE,SF_STACK,SF_LIST;
00065 
00066 
00067 
00068 /*
00069 *  Linked List Interface
00070 */ 
00071 SF_LIST * sflist_new ( void ); 
00072 void      sflist_init ( SF_LIST * s); 
00073 int       sflist_add_tail ( SF_LIST* s, NODE_DATA ndata );
00074 int       sflist_add_head ( SF_LIST* s, NODE_DATA ndata );
00075 int       sflist_add_before ( SF_LIST* s, SF_LNODE * lnode, NODE_DATA ndata );
00076 NODE_DATA sflist_remove_head ( SF_LIST * s);
00077 NODE_DATA sflist_remove_tail ( SF_LIST * s); 
00078 NODE_DATA sflist_remove_current ( SF_LIST * s); 
00079 int       sflist_count ( SF_LIST* s); 
00080 NODE_DATA sflist_first( SF_LIST * s);
00081 NODE_DATA sflist_next( SF_LIST * s);
00082 NODE_DATA sflist_prev( SF_LIST * s);
00083 SF_LNODE *sflist_first_node( SF_LIST * s );
00084 SF_LNODE *sflist_next_node( SF_LIST * s );
00085 void      sflist_free ( SF_LIST * s); 
00086 void      sflist_free_all( SF_LIST * s, void (*free)(void*) ); 
00087 
00088 /*
00089 *   Stack Interface ( LIFO - Last in, First out ) 
00090 */
00091 SF_STACK *sfstack_new ( void ); 
00092 void      sfstack_init ( SF_STACK * s); 
00093 int       sfstack_add( SF_STACK* s, NODE_DATA ndata ); 
00094 NODE_DATA sfstack_remove ( SF_STACK * s);
00095 int       sfstack_count ( SF_STACK * s); 
00096 void      sfstack_free ( SF_STACK * s); 
00097 void      sfstack_free_all( SF_STACK* s, void (*free)(void*) ); 
00098 
00099 /*
00100 *   Queue Interface ( FIFO - First in, First out ) 
00101 */
00102 SF_QUEUE *sfqueue_new ( void ); 
00103 void      sfqueue_init ( SF_QUEUE * s); 
00104 int       sfqueue_add( SF_QUEUE * s, NODE_DATA ndata ); 
00105 NODE_DATA sfqueue_remove ( SF_QUEUE * s);
00106 int       sfqueue_count ( SF_QUEUE * s); 
00107 void      sfqueue_free ( SF_QUEUE * s); 
00108 void      sfqueue_free_all( SF_QUEUE* s, void (*free)(void*) ); 
00109 
00110 /*
00111 * Performance Stack functions for Integer/Unsigned and Pointers, uses
00112 * user provided array storage, perhaps from the program stack or a global.
00113 * These are efficient, and use no memory functions.
00114 */
00115 int sfistack_init( SF_ISTACK * s, unsigned * a,  int n  );
00116 int sfistack_push( SF_ISTACK *s, unsigned value);
00117 int sfistack_pop(  SF_ISTACK *s, unsigned * value);
00118 
00119 int sfpstack_init( SF_PSTACK * s, void ** a,  int n  );
00120 int sfpstack_push( SF_PSTACK *s, void * value);
00121 int sfpstack_pop(  SF_PSTACK *s, void ** value);
00122 
00123 #endif

Generated on Sun May 14 14:51:18 2006 by  doxygen 1.4.2