#include "mvc.h"
ABC_NAMESPACE_IMPL_START
void Mvc_ListAddCubeHead_( Mvc_List_t * pList, Mvc_Cube_t * pCube )
{
if ( pList->pHead == NULL )
{
Mvc_CubeSetNext( pCube, NULL );
pList->pHead = pCube;
pList->pTail = pCube;
}
else
{
Mvc_CubeSetNext( pCube, pList->pHead );
pList->pHead = pCube;
}
pList->nItems++;
}
void Mvc_ListAddCubeTail_( Mvc_List_t * pList, Mvc_Cube_t * pCube )
{
if ( pList->pHead == NULL )
pList->pHead = pCube;
else
Mvc_CubeSetNext( pList->pTail, pCube );
pList->pTail = pCube;
Mvc_CubeSetNext( pCube, NULL );
pList->nItems++;
}
void Mvc_ListDeleteCube_( Mvc_List_t * pList, Mvc_Cube_t * pPrev, Mvc_Cube_t * pCube )
{
if ( pPrev == NULL ) pList->pHead = Mvc_CubeReadNext(pCube);
else
pPrev->pNext = pCube->pNext;
if ( pList->pTail == pCube ) {
assert( Mvc_CubeReadNext(pCube) == NULL );
pList->pTail = pPrev;
}
pList->nItems--;
}
void Mvc_CoverAddCubeHead_( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
{
Mvc_List_t * pList = &pCover->lCubes;
if ( pList->pHead == NULL )
{
Mvc_CubeSetNext( pCube, NULL );
pList->pHead = pCube;
pList->pTail = pCube;
}
else
{
Mvc_CubeSetNext( pCube, pList->pHead );
pList->pHead = pCube;
}
pList->nItems++;
}
void Mvc_CoverAddCubeTail_( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
{
Mvc_List_t * pList = &pCover->lCubes;
if ( pList->pHead == NULL )
pList->pHead = pCube;
else
Mvc_CubeSetNext( pList->pTail, pCube );
pList->pTail = pCube;
Mvc_CubeSetNext( pCube, NULL );
pList->nItems++;
}
void Mvc_CoverDeleteCube_( Mvc_Cover_t * pCover, Mvc_Cube_t * pPrev, Mvc_Cube_t * pCube )
{
Mvc_List_t * pList = &pCover->lCubes;
if ( pPrev == NULL ) pList->pHead = Mvc_CubeReadNext(pCube);
else
pPrev->pNext = pCube->pNext;
if ( pList->pTail == pCube ) {
assert( Mvc_CubeReadNext(pCube) == NULL );
pList->pTail = pPrev;
}
pList->nItems--;
}
void Mvc_CoverAddDupCubeHead( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
{
Mvc_Cube_t * pCubeNew;
pCubeNew = Mvc_CubeAlloc( pCover );
Mvc_CubeBitCopy( pCubeNew, pCube );
Mvc_CoverAddCubeHead( pCover, pCubeNew );
}
void Mvc_CoverAddDupCubeTail( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
{
Mvc_Cube_t * pCubeNew;
pCubeNew = Mvc_CubeAlloc( pCover );
Mvc_CubeBitCopy( pCubeNew, pCube );
Mvc_CoverAddCubeTail( pCover, pCubeNew );
}
void Mvc_CoverAddLiteralsOfCube( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
{
}
void Mvc_CoverDeleteLiteralsOfCube( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube )
{
}
void Mvc_CoverList2Array( Mvc_Cover_t * pCover )
{
Mvc_Cube_t * pCube;
int Counter;
Mvc_CoverAllocateArrayCubes( pCover );
Counter = 0;
Mvc_CoverForEachCube( pCover, pCube )
pCover->pCubes[ Counter++ ] = pCube;
assert( Counter == Mvc_CoverReadCubeNum(pCover) );
}
void Mvc_CoverArray2List( Mvc_Cover_t * pCover )
{
Mvc_Cube_t * pCube;
int nCubes, i;
assert( pCover->pCubes );
nCubes = Mvc_CoverReadCubeNum(pCover);
if ( nCubes == 0 )
return;
if ( nCubes == 1 )
{
pCube = pCover->pCubes[0];
pCube->pNext = NULL;
pCover->lCubes.pHead = pCover->lCubes.pTail = pCube;
return;
}
pCube = pCover->pCubes[0];
pCover->lCubes.pHead = pCube;
pCube = pCover->pCubes[nCubes-1];
pCube->pNext = NULL;
pCover->lCubes.pTail = pCube;
for ( i = 0; i < nCubes - 1; i++ )
pCover->pCubes[i]->pNext = pCover->pCubes[i+1];
}
Mvc_Cube_t * Mvc_ListGetTailFromHead( Mvc_Cube_t * pHead )
{
Mvc_Cube_t * pCube, * pTail;
for ( pTail = pCube = pHead;
pCube;
pTail = pCube, pCube = Mvc_CubeReadNext(pCube) );
return pTail;
}
ABC_NAMESPACE_IMPL_END