diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2007-09-30 08:01:00 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2007-09-30 08:01:00 -0700 |
commit | e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7 (patch) | |
tree | de3ffe87c3e17950351e3b7d97fa18318bd5ea9a /src/misc/mvc/mvcSort.c | |
parent | 7d7e60f2dc84393cd4c5db22d2eaf7b1fb1a79b2 (diff) | |
download | abc-e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7.tar.gz abc-e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7.tar.bz2 abc-e54d9691616b9a0326e2fdb3156bb4eeb8abfcd7.zip |
Version abc70930
Diffstat (limited to 'src/misc/mvc/mvcSort.c')
-rw-r--r-- | src/misc/mvc/mvcSort.c | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/src/misc/mvc/mvcSort.c b/src/misc/mvc/mvcSort.c deleted file mode 100644 index 3c975cb3..00000000 --- a/src/misc/mvc/mvcSort.c +++ /dev/null @@ -1,141 +0,0 @@ -/**CFile**************************************************************** - - FileName [mvcSort.c] - - PackageName [MVSIS 2.0: Multi-valued logic synthesis system.] - - Synopsis [Sorting cubes in the cover with the mask.] - - Author [MVSIS Group] - - Affiliation [uC Berkeley] - - Date [Ver. 1.0. Started - February 1, 2003.] - - Revision [$Id: mvcSort.c,v 1.5 2003/04/27 01:03:45 wjiang Exp $] - -***********************************************************************/ - -#include "mvc.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - - -Mvc_Cube_t * Mvc_CoverSort_rec( Mvc_Cube_t * pList, int nItems, Mvc_Cube_t * pMask, int (* pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *) ); -Mvc_Cube_t * Mvc_CoverSortMerge( Mvc_Cube_t * pList1, Mvc_Cube_t * pList2, Mvc_Cube_t * pMask, int (* pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *) ); - -//////////////////////////////////////////////////////////////////////// -/// FuNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Sorts cubes using the given cost function.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Mvc_CoverSort( Mvc_Cover_t * pCover, Mvc_Cube_t * pMask, int (* pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *) ) -{ - Mvc_Cube_t * pHead; - int nCubes; - // one cube does not need sorting - nCubes = Mvc_CoverReadCubeNum(pCover); - if ( nCubes <= 1 ) - return; - // sort the cubes - pHead = Mvc_CoverSort_rec( Mvc_CoverReadCubeHead(pCover), nCubes, pMask, pCompareFunc ); - // insert the sorted list into the cover - Mvc_CoverSetCubeHead( pCover, pHead ); - Mvc_CoverSetCubeTail( pCover, Mvc_ListGetTailFromHead(pHead) ); - // make sure that the list is sorted in the increasing order - assert( pCompareFunc( Mvc_CoverReadCubeHead(pCover), Mvc_CoverReadCubeTail(pCover), pMask ) <= 0 ); -} - -/**Function************************************************************* - - Synopsis [Recursive part of Mvc_CoverSort()] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Mvc_Cube_t * Mvc_CoverSort_rec( Mvc_Cube_t * pList, int nItems, Mvc_Cube_t * pMask, int (* pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *) ) -{ - Mvc_Cube_t * pList1, * pList2; - int nItems1, nItems2, i; - - // trivial case - if ( nItems == 1 ) - { - Mvc_CubeSetNext( pList, NULL ); - return pList; - } - - // select the new sizes - nItems1 = nItems/2; - nItems2 = nItems - nItems1; - - // set the new beginnings - pList1 = pList2 = pList; - for ( i = 0; i < nItems1; i++ ) - pList2 = Mvc_CubeReadNext( pList2 ); - - // solve recursively - pList1 = Mvc_CoverSort_rec( pList1, nItems1, pMask, pCompareFunc ); - pList2 = Mvc_CoverSort_rec( pList2, nItems2, pMask, pCompareFunc ); - - // merge - return Mvc_CoverSortMerge( pList1, pList2, pMask, pCompareFunc ); -} - - -/**Function************************************************************* - - Synopsis [Merges two NULL-terminated linked lists.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Mvc_Cube_t * Mvc_CoverSortMerge( Mvc_Cube_t * pList1, Mvc_Cube_t * pList2, Mvc_Cube_t * pMask, int (* pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *) ) -{ - Mvc_Cube_t * pList = NULL, ** ppTail = &pList; - Mvc_Cube_t * pCube; - while ( pList1 && pList2 ) - { - if ( pCompareFunc( pList1, pList2, pMask ) < 0 ) - { - pCube = pList1; - pList1 = Mvc_CubeReadNext(pList1); - } - else - { - pCube = pList2; - pList2 = Mvc_CubeReadNext(pList2); - } - *ppTail = pCube; - ppTail = Mvc_CubeReadNextP(pCube); - } - *ppTail = pList1? pList1: pList2; - return pList; -} - - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - |