00001 00019 #include "mvc.h" 00020 00024 00028 00040 int Mvc_CoverReadWordNum( Mvc_Cover_t * pCover ) { return pCover->nWords; } 00041 int Mvc_CoverReadBitNum( Mvc_Cover_t * pCover ) { return pCover->nBits; } 00042 int Mvc_CoverReadCubeNum( Mvc_Cover_t * pCover ) { return pCover->lCubes.nItems; } 00043 Mvc_Cube_t * Mvc_CoverReadCubeHead( Mvc_Cover_t * pCover ) { return pCover->lCubes.pHead; } 00044 Mvc_Cube_t * Mvc_CoverReadCubeTail( Mvc_Cover_t * pCover ) { return pCover->lCubes.pTail; } 00045 Mvc_List_t * Mvc_CoverReadCubeList( Mvc_Cover_t * pCover ) { return &pCover->lCubes; } 00046 00047 00059 int Mvc_ListReadCubeNum( Mvc_List_t * pList ) { return pList->nItems; } 00060 Mvc_Cube_t * Mvc_ListReadCubeHead( Mvc_List_t * pList ) { return pList->pHead; } 00061 Mvc_Cube_t * Mvc_ListReadCubeTail( Mvc_List_t * pList ) { return pList->pTail; } 00062 00074 void Mvc_CoverSetCubeNum( Mvc_Cover_t * pCover,int nItems ) { pCover->lCubes.nItems = nItems; } 00075 void Mvc_CoverSetCubeHead( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube ) { pCover->lCubes.pHead = pCube; } 00076 void Mvc_CoverSetCubeTail( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube ) { pCover->lCubes.pTail = pCube; } 00077 void Mvc_CoverSetCubeList( Mvc_Cover_t * pCover, Mvc_List_t * pList ) { pCover->lCubes = *pList; } 00078 00090 int Mvc_CoverIsEmpty( Mvc_Cover_t * pCover ) 00091 { 00092 return Mvc_CoverReadCubeNum(pCover) == 0; 00093 } 00094 00106 int Mvc_CoverIsTautology( Mvc_Cover_t * pCover ) 00107 { 00108 Mvc_Cube_t * pCube; 00109 int iBit, Value; 00110 00111 if ( Mvc_CoverReadCubeNum(pCover) != 1 ) 00112 return 0; 00113 00114 pCube = Mvc_CoverReadCubeHead( pCover ); 00115 Mvc_CubeForEachBit( pCover, pCube, iBit, Value ) 00116 if ( Value == 0 ) 00117 return 0; 00118 return 1; 00119 } 00120 00132 int Mvc_CoverIsBinaryBuffer( Mvc_Cover_t * pCover ) 00133 { 00134 Mvc_Cube_t * pCube; 00135 if ( pCover->nBits != 2 ) 00136 return 0; 00137 if ( Mvc_CoverReadCubeNum(pCover) != 1 ) 00138 return 0; 00139 pCube = pCover->lCubes.pHead; 00140 if ( Mvc_CubeBitValue(pCube, 0) == 0 && Mvc_CubeBitValue(pCube, 1) == 1 ) 00141 return 1; 00142 return 0; 00143 } 00144 00145 00157 void Mvc_CoverMakeEmpty( Mvc_Cover_t * pCover ) 00158 { 00159 Mvc_Cube_t * pCube, * pCube2; 00160 Mvc_CoverForEachCubeSafe( pCover, pCube, pCube2 ) 00161 Mvc_CubeFree( pCover, pCube ); 00162 pCover->lCubes.nItems = 0; 00163 pCover->lCubes.pHead = NULL; 00164 pCover->lCubes.pTail = NULL; 00165 } 00166 00178 void Mvc_CoverMakeTautology( Mvc_Cover_t * pCover ) 00179 { 00180 Mvc_Cube_t * pCubeNew; 00181 Mvc_CoverMakeEmpty( pCover ); 00182 pCubeNew = Mvc_CubeAlloc( pCover ); 00183 Mvc_CubeBitFill( pCubeNew ); 00184 Mvc_CoverAddCubeTail( pCover, pCubeNew ); 00185 } 00186 00187 00199 Mvc_Cover_t * Mvc_CoverCreateEmpty( Mvc_Cover_t * pCover ) 00200 { 00201 Mvc_Cover_t * pCoverNew; 00202 pCoverNew = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00203 return pCoverNew; 00204 } 00205 00217 Mvc_Cover_t * Mvc_CoverCreateTautology( Mvc_Cover_t * pCover ) 00218 { 00219 Mvc_Cube_t * pCubeNew; 00220 Mvc_Cover_t * pCoverNew; 00221 pCoverNew = Mvc_CoverAlloc( pCover->pMem, pCover->nBits ); 00222 pCubeNew = Mvc_CubeAlloc( pCoverNew ); 00223 Mvc_CubeBitFill( pCubeNew ); 00224 Mvc_CoverAddCubeTail( pCoverNew, pCubeNew ); 00225 return pCoverNew; 00226 } 00227 00228 00232 00233