ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
xsatUtils.h
Go to the documentation of this file.
1
21#ifndef ABC__sat__xSAT__xsatUtils_h
22#define ABC__sat__xSAT__xsatUtils_h
23
28
30
42static inline void xSAT_UtilSelectSort( void** pArray, int nSize, int(* CompFnct )( const void *, const void * ) )
43{
44 int i, j, iBest;
45 void* pTmp;
46
47 for ( i = 0; i < ( nSize - 1 ); i++ )
48 {
49 iBest = i;
50 for ( j = i + 1; j < nSize; j++ )
51 {
52 if ( CompFnct( pArray[j], pArray[iBest] ) )
53 iBest = j;
54 }
55 pTmp = pArray[i];
56 pArray[i] = pArray[iBest];
57 pArray[iBest] = pTmp;
58 }
59}
60
72static void xSAT_UtilSort( void** pArray, int nSize, int(* CompFnct )( const void *, const void *) )
73{
74 if ( nSize <= 15 )
75 xSAT_UtilSelectSort( pArray, nSize, CompFnct );
76 else
77 {
78 void* pPivot = pArray[nSize / 2];
79 void* pTmp;
80 int i = -1;
81 int j = nSize;
82
83 for(;;)
84 {
85 do i++; while( CompFnct( pArray[i], pPivot ) );
86 do j--; while( CompFnct( pPivot, pArray[j] ) );
87
88 if ( i >= j )
89 break;
90
91 pTmp = pArray[i];
92 pArray[i] = pArray[j];
93 pArray[j] = pTmp;
94 }
95
96 xSAT_UtilSort( pArray, i, CompFnct );
97 xSAT_UtilSort( pArray + i, ( nSize - i ), CompFnct );
98 }
99}
100
102
103#endif
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.