00001
00019 #include "mvc.h"
00020
00024
00028
00040 void Mvc_ListAddCubeHead_( Mvc_List_t * pList, Mvc_Cube_t * pCube )
00041 {
00042 if ( pList->pHead == NULL )
00043 {
00044 Mvc_CubeSetNext( pCube, NULL );
00045 pList->pHead = pCube;
00046 pList->pTail = pCube;
00047 }
00048 else
00049 {
00050 Mvc_CubeSetNext( pCube, pList->pHead );
00051 pList->pHead = pCube;
00052 }
00053 pList->nItems++;
00054 }
00055
00056
00068 void Mvc_ListAddCubeTail_( Mvc_List_t * pList, Mvc_Cube_t * pCube )
00069 {
00070 if ( pList->pHead == NULL )
00071 pList->pHead = pCube;
00072 else
00073 Mvc_CubeSetNext( pList->pTail, pCube );
00074 pList->pTail = pCube;
00075 Mvc_CubeSetNext( pCube, NULL );
00076 pList->nItems++;
00077 }
00078
00079
00091 void Mvc_ListDeleteCube_( Mvc_List_t * pList, Mvc_Cube_t * pPrev, Mvc_Cube_t * pCube )
00092 {
00093 if ( pPrev == NULL )
00094 pList->pHead = Mvc_CubeReadNext(pCube);
00095 else
00096 pPrev->pNext = pCube->pNext;
00097 if ( pList->pTail == pCube )
00098 {
00099 assert( Mvc_CubeReadNext(pCube) == NULL );
00100 pList->pTail = pPrev;
00101 }
00102 pList->nItems--;
00103 }
00104
00105
00106
00118 void Mvc_CoverAddCubeHead_( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
00119 {
00120 Mvc_List_t * pList = &pCover->lCubes;
00121 if ( pList->pHead == NULL )
00122 {
00123 Mvc_CubeSetNext( pCube, NULL );
00124 pList->pHead = pCube;
00125 pList->pTail = pCube;
00126 }
00127 else
00128 {
00129 Mvc_CubeSetNext( pCube, pList->pHead );
00130 pList->pHead = pCube;
00131 }
00132 pList->nItems++;
00133 }
00134
00146 void Mvc_CoverAddCubeTail_( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
00147 {
00148 Mvc_List_t * pList = &pCover->lCubes;
00149
00150 if ( pList->pHead == NULL )
00151 pList->pHead = pCube;
00152 else
00153 Mvc_CubeSetNext( pList->pTail, pCube );
00154 pList->pTail = pCube;
00155 Mvc_CubeSetNext( pCube, NULL );
00156 pList->nItems++;
00157 }
00158
00170 void Mvc_CoverDeleteCube_( Mvc_Cover_t * pCover, Mvc_Cube_t * pPrev, Mvc_Cube_t * pCube )
00171 {
00172 Mvc_List_t * pList = &pCover->lCubes;
00173
00174 if ( pPrev == NULL )
00175 pList->pHead = Mvc_CubeReadNext(pCube);
00176 else
00177 pPrev->pNext = pCube->pNext;
00178 if ( pList->pTail == pCube )
00179 {
00180 assert( Mvc_CubeReadNext(pCube) == NULL );
00181 pList->pTail = pPrev;
00182 }
00183 pList->nItems--;
00184 }
00185
00186
00187
00199 void Mvc_CoverAddDupCubeHead( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
00200 {
00201 Mvc_Cube_t * pCubeNew;
00202 pCubeNew = Mvc_CubeAlloc( pCover );
00203 Mvc_CubeBitCopy( pCubeNew, pCube );
00204 Mvc_CoverAddCubeHead( pCover, pCubeNew );
00205 }
00206
00218 void Mvc_CoverAddDupCubeTail( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
00219 {
00220 Mvc_Cube_t * pCubeNew;
00221
00222 pCubeNew = Mvc_CubeAlloc( pCover );
00223 Mvc_CubeBitCopy( pCubeNew, pCube );
00224
00225
00226
00227 Mvc_CoverAddCubeTail( pCover, pCubeNew );
00228 }
00229
00230
00242 void Mvc_CoverAddLiteralsOfCube( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
00243 {
00244
00245
00246
00247
00248
00249 }
00250
00262 void Mvc_CoverDeleteLiteralsOfCube( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
00263 {
00264
00265
00266
00267
00268
00269 }
00270
00271
00283 void Mvc_CoverList2Array( Mvc_Cover_t * pCover )
00284 {
00285 Mvc_Cube_t * pCube;
00286 int Counter;
00287
00288 Mvc_CoverAllocateArrayCubes( pCover );
00289
00290 Counter = 0;
00291 Mvc_CoverForEachCube( pCover, pCube )
00292 pCover->pCubes[ Counter++ ] = pCube;
00293 assert( Counter == Mvc_CoverReadCubeNum(pCover) );
00294 }
00295
00307 void Mvc_CoverArray2List( Mvc_Cover_t * pCover )
00308 {
00309 Mvc_Cube_t * pCube;
00310 int nCubes, i;
00311
00312 assert( pCover->pCubes );
00313
00314 nCubes = Mvc_CoverReadCubeNum(pCover);
00315 if ( nCubes == 0 )
00316 return;
00317 if ( nCubes == 1 )
00318 {
00319 pCube = pCover->pCubes[0];
00320 pCube->pNext = NULL;
00321 pCover->lCubes.pHead = pCover->lCubes.pTail = pCube;
00322 return;
00323 }
00324
00325 pCube = pCover->pCubes[0];
00326 pCover->lCubes.pHead = pCube;
00327
00328 pCube = pCover->pCubes[nCubes-1];
00329 pCube->pNext = NULL;
00330 pCover->lCubes.pTail = pCube;
00331
00332
00333 for ( i = 0; i < nCubes - 1; i++ )
00334 pCover->pCubes[i]->pNext = pCover->pCubes[i+1];
00335 }
00336
00348 Mvc_Cube_t * Mvc_ListGetTailFromHead( Mvc_Cube_t * pHead )
00349 {
00350 Mvc_Cube_t * pCube, * pTail;
00351 for ( pTail = pCube = pHead;
00352 pCube;
00353 pTail = pCube, pCube = Mvc_CubeReadNext(pCube) );
00354 return pTail;
00355 }
00356
00357
00361
00362