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

  Synopsis    [Adds the cube to storage.]

  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.
  Do not forget to clean the storage!]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Adds the cube to storage.]

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.
Do not forget to clean the storage!]




Function Synopsis [ Adds the cube to storage . ] 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 . Do not forget to clean the storage! ]
int Min_EsopAddCubeInt( Min_Man_t * p, Min_Cube_t * pCube )
{
    Min_Cube_t * pThis, ** ppPrev;
    Min_CoverForEachCubePrev( p->ppStore[pCube->nLits], pThis, ppPrev )
    {
        if ( Min_CubesAreEqual( pCube, pThis ) )
        {
            *ppPrev = pThis->pNext;
            Min_CubeRecycle( p, pCube );
            Min_CubeRecycle( p, pThis );
            p->nCubes--;
            return 0;
        }
    }
    if ( pCube->nLits < pCube->nVars )
    Min_CoverForEachCubePrev( p->ppStore[pCube->nLits+1], pThis, ppPrev )
    {
        if ( Min_CubesDistOne( pCube, pThis, p->pTemp ) )
        {
            *ppPrev = pThis->pNext;
            Min_CubesTransform( pCube, pThis, p->pTemp );
            pCube->nLits++;
            Min_CubeRecycle( p, pThis );
            p->nCubes--;
            return 1;
        }
    }
    Min_CoverForEachCubePrev( p->ppStore[pCube->nLits], pThis, ppPrev )
    {
        if ( Min_CubesDistOne( pCube, pThis, p->pTemp ) )
        {
            *ppPrev = pThis->pNext;
            Min_CubesTransform( pCube, pThis, p->pTemp );
            pCube->nLits--;
            Min_CubeRecycle( p, pThis );
            p->nCubes--;
            return 1;
        }
    }
    if ( pCube->nLits > 0 )
    Min_CoverForEachCubePrev( p->ppStore[pCube->nLits-1], pThis, ppPrev )
    {
        if ( Min_CubesDistOne( pCube, pThis, p->pTemp ) )
        {
            *ppPrev = pThis->pNext;
            Min_CubesTransform( pCube, pThis, p->pTemp );
            Min_CubeRecycle( p, pThis );
            p->nCubes--;
            return 1;
        }
    }
    pCube->pNext = p->ppStore[pCube->nLits];
    p->ppStore[pCube->nLits] = pCube;
    p->nCubes++;
    return 0;
}
int Min_EsopAddCubeInt ( Min_Man_t * p , Min_Cube_t * pCube ) { Min_Cube_t * pThis , * * ppPrev ; Min_CoverForEachCubePrev ( p -> ppStore [ pCube -> nLits ] , pThis , ppPrev ) { if ( Min_CubesAreEqual ( pCube , pThis ) ) { * ppPrev = pThis -> pNext ; Min_CubeRecycle ( p , pCube ) ; Min_CubeRecycle ( p , pThis ) ; p -> nCubes -- ; return 0 ; } } if ( pCube -> nLits < pCube -> nVars ) Min_CoverForEachCubePrev ( p -> ppStore [ pCube -> nLits + 1 ] , pThis , ppPrev ) { if ( Min_CubesDistOne ( pCube , pThis , p -> pTemp ) ) { * ppPrev = pThis -> pNext ; Min_CubesTransform ( pCube , pThis , p -> pTemp ) ; pCube -> nLits ++ ; Min_CubeRecycle ( p , pThis ) ; p -> nCubes -- ; return 1 ; } } Min_CoverForEachCubePrev ( p -> ppStore [ pCube -> nLits ] , pThis , ppPrev ) { if ( Min_CubesDistOne ( pCube , pThis , p -> pTemp ) ) { * ppPrev = pThis -> pNext ; Min_CubesTransform ( pCube , pThis , p -> pTemp ) ; pCube -> nLits -- ; Min_CubeRecycle ( p , pThis ) ; p -> nCubes -- ; return 1 ; } } if ( pCube -> nLits > 0 ) Min_CoverForEachCubePrev ( p -> ppStore [ pCube -> nLits - 1 ] , pThis , ppPrev ) { if ( Min_CubesDistOne ( pCube , pThis , p -> pTemp ) ) { * ppPrev = pThis -> pNext ; Min_CubesTransform ( pCube , pThis , p -> pTemp ) ; Min_CubeRecycle ( p , pThis ) ; p -> nCubes -- ; return 1 ; } } pCube -> pNext = p -> ppStore [ pCube -> nLits ] ; p -> ppStore [ pCube -> nLits ] = pCube ; p -> nCubes ++ ; return 0 ; }
Function
Synopsis    [Adds the cube to storage.]
Function Synopsis [ Adds the cube to storage . ]
// try to find the identical cube // find a distance-1 cube if it exists // add the cube