Go to the documentation of this file.00001
00031 #ifndef _VSET_H_
00032 #define _VSET_H_
00033
00034 #include <maloc/maloc_base.h>
00035
00036 #include <maloc/vnm.h>
00037 #include <maloc/vmem.h>
00038
00039
00040
00041
00042
00043
00044
00046 typedef struct Vset {
00047
00048 Vmem *vmem;
00049 int iMadeVmem;
00051 int curT;
00053 char nameT[VMAX_ARGLEN];
00054 int sizeT;
00056 int numBlocks;
00057 int numT;
00058 int prtT;
00060 int maxObjects;
00061 int blockPower;
00062 int blockSize;
00063 int blockMax;
00064 int blockModulo;
00066 char **table;
00068 } Vset;
00069
00070
00071 #if !defined(VINLINE_MALOC)
00072
00073 VEXTERNC int Vset_num(Vset *thee);
00075 VEXTERNC char *Vset_access(Vset *thee, int i);
00077 VEXTERNC char *Vset_create(Vset *thee);
00079 VEXTERNC char *Vset_first(Vset *thee);
00081 VEXTERNC char *Vset_last(Vset *thee);
00083 VEXTERNC char *Vset_next(Vset *thee);
00085 VEXTERNC char *Vset_prev(Vset *thee);
00087 VEXTERNC char *Vset_peekFirst(Vset *thee);
00089 VEXTERNC char *Vset_peekLast(Vset *thee);
00091 VEXTERNC void Vset_destroy(Vset *thee);
00092 #else
00093
00094 # define Vset_num(thee) ((thee)->numT)
00095
00096 # define Vset_access(thee,i) ( \
00097 ((i >= 0) && (i < thee->numT)) \
00098 ? &((thee)->table[ (i)>>(thee)->blockPower ] \
00099 [ (thee)->sizeT*((i)&(thee)->blockModulo) ]) \
00100 : VNULL \
00101 )
00102
00103 # define Vset_create(thee) ( \
00104 ( ((((thee)->numT)>>(thee)->blockPower) >= (thee)->numBlocks) \
00105 || ((((thee)->numT+1)%(thee)->prtT) == 0) ) \
00106 ? (Vset_createLast((thee))) \
00107 : (++((thee)->numT), (Vset_access((thee),(thee)->numT-1))) \
00108 )
00109
00110 # define Vset_first(thee) ( \
00111 (thee)->curT = 0, \
00112 Vset_access((thee), (thee)->curT) \
00113 )
00114
00115 # define Vset_last(thee) ( \
00116 (thee)->curT = (thee)->numT-1, \
00117 Vset_access((thee), (thee)->curT) \
00118 )
00119
00120 # define Vset_next(thee) ( \
00121 (thee)->curT++, \
00122 ((thee)->curT < (thee)->numT) \
00123 ? Vset_access((thee), (thee)->curT) \
00124 : VNULL \
00125 )
00126
00127 # define Vset_prev(thee) ( \
00128 (thee)->curT--, \
00129 ((thee)->curT >= 0) \
00130 ? Vset_access((thee), (thee)->curT) \
00131 : VNULL \
00132 )
00133
00134 # define Vset_peekFirst(thee) ( \
00135 Vset_access((thee), 0) \
00136 )
00137
00138 # define Vset_peekLast(thee) ( \
00139 Vset_access((thee), (thee)->numT-1) \
00140 )
00141
00142 # define Vset_destroy(thee) ( \
00143 ( ((((thee)->numT-1)>>(thee)->blockPower) < (thee)->numBlocks-1) \
00144 || ((thee)->numT == 1) || ((((thee)->numT)%(thee)->prtT) == 0) ) \
00145 ? (Vset_destroyLast((thee))) : (void)(((thee)->numT)--) \
00146 )
00147 #endif
00148
00150 VEXTERNC Vset* Vset_ctor(Vmem *vmem,
00151 const char *tname, int tsize, int tmaxNum, int ioKey);
00153 VEXTERNC void Vset_dtor(Vset **thee);
00154
00156 VEXTERNC char *Vset_createLast(Vset *thee);
00158 VEXTERNC void Vset_destroyLast(Vset *thee);
00160 VEXTERNC void Vset_initData(Vset *thee);
00162 VEXTERNC void Vset_reset(Vset *thee);
00164 VEXTERNC void Vset_check(Vset *thee,
00165 int *tnum, int *tsize, int *tVecUse, int *tVecMal, int *tVecOhd);
00166
00168 VEXTERNC void Vset_memChk(Vset *thee);
00169
00170 #endif
00171