abc/src/map/cov/covMinSop.c
/**Function*************************************************************

  Synopsis    [Adds cube to the SOP cover stored in the manager.]

  Description [Returns 0 if the cube is added or removed. Returns 1
  if the cube is glued with some other cube and has to be added again.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Adds cube to the SOP cover stored in the manager.]

Description [Returns 0 if the cube is added or removed. Returns 1
if the cube is glued with some other cube and has to be added again.]




Function Synopsis [ Adds cube to the SOP cover stored in the manager . ] Description [ Returns 0 if the cube is added or removed . Returns 1 if the cube is glued with some other cube and has to be added again . ]
int Min_SopAddCubeInt( Min_Man_t * p, Min_Cube_t * pCube )
{
    Min_Cube_t * pThis, * pThis2, ** ppPrev;
    int i;
    Min_CoverForEachCube( p->ppStore[pCube->nLits], pThis )
    {
        if ( Min_CubesAreEqual( pCube, pThis ) )
        {
            Min_CubeRecycle( p, pCube );
            return 0;
        }
    }
    for ( i = 0; i < (int)pCube->nLits; i++ )
    Min_CoverForEachCube( p->ppStore[i], pThis )
    {
        if ( pThis != p->pBubble && Min_CubeIsContained( pThis, pCube ) )
        {
            Min_CubeRecycle( p, pCube );
            return 0;
        }
    }
    Min_CoverForEachCubePrev( p->ppStore[pCube->nLits], pThis, ppPrev )
    {
        if ( Min_CubesDistOne( pCube, pThis, NULL ) )
        {
            *ppPrev = pThis->pNext;
            Min_CubesTransformOr( pCube, pThis );
            pCube->nLits--;
            Min_CubeRecycle( p, pThis );
            p->nCubes--;
            return 1;
        }
    }
    for ( i = pCube->nLits + 1; i <= (int)pCube->nVars; i++ )
    {
        ppPrev = &p->ppStore[i];
        Min_CoverForEachCubeSafe( p->ppStore[i], pThis, pThis2 )
        {
            if ( pThis != p->pBubble && Min_CubeIsContained( pCube, pThis ) )
            {
                *ppPrev = pThis->pNext;
                Min_CubeRecycle( p, pThis );
                p->nCubes--;
            }
            else
                ppPrev = &pThis->pNext;
        }
    }
    pCube->pNext = p->ppStore[pCube->nLits];
    p->ppStore[pCube->nLits] = pCube;
    p->nCubes++;
    return 0;
}
int Min_SopAddCubeInt ( Min_Man_t * p , Min_Cube_t * pCube ) { Min_Cube_t * pThis , * pThis2 , * * ppPrev ; int i ; Min_CoverForEachCube ( p -> ppStore [ pCube -> nLits ] , pThis ) { if ( Min_CubesAreEqual ( pCube , pThis ) ) { Min_CubeRecycle ( p , pCube ) ; return 0 ; } } for ( i = 0 ; i < ( int ) pCube -> nLits ; i ++ ) Min_CoverForEachCube ( p -> ppStore [ i ] , pThis ) { if ( pThis != p -> pBubble && Min_CubeIsContained ( pThis , pCube ) ) { Min_CubeRecycle ( p , pCube ) ; return 0 ; } } Min_CoverForEachCubePrev ( p -> ppStore [ pCube -> nLits ] , pThis , ppPrev ) { if ( Min_CubesDistOne ( pCube , pThis , NULL ) ) { * ppPrev = pThis -> pNext ; Min_CubesTransformOr ( pCube , pThis ) ; pCube -> nLits -- ; Min_CubeRecycle ( p , pThis ) ; p -> nCubes -- ; return 1 ; } } for ( i = pCube -> nLits + 1 ; i <= ( int ) pCube -> nVars ; i ++ ) { ppPrev = & p -> ppStore [ i ] ; Min_CoverForEachCubeSafe ( p -> ppStore [ i ] , pThis , pThis2 ) { if ( pThis != p -> pBubble && Min_CubeIsContained ( pCube , pThis ) ) { * ppPrev = pThis -> pNext ; Min_CubeRecycle ( p , pThis ) ; p -> nCubes -- ; } else ppPrev = & pThis -> pNext ; } } pCube -> pNext = p -> ppStore [ pCube -> nLits ] ; p -> ppStore [ pCube -> nLits ] = pCube ; p -> nCubes ++ ; return 0 ; }
Function
Synopsis    [Adds cube to the SOP cover stored in the manager.]
Function Synopsis [ Adds cube to the SOP cover stored in the manager . ]
// try to find the identical cube // try to find a containing cube // try to find distance one in the same bin // clean the other cubes using this one // add the cube