summaryrefslogtreecommitdiffstats
path: root/src/sat/xsat/xsatUtils.h
diff options
context:
space:
mode:
authorMathias Soeken <mathias.soeken@gmail.com>2017-02-22 19:00:28 -0800
committerMathias Soeken <mathias.soeken@gmail.com>2017-02-22 19:00:28 -0800
commit28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e (patch)
tree6b7962dc72653e3bf615c5901854774eca9d23c8 /src/sat/xsat/xsatUtils.h
parent5af44731bff0061c724912cf76e86dddbb4f2c7a (diff)
parentdd8cc7e9a27e2bd962d612911c6fd9508c6c1e0d (diff)
downloadabc-28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e.tar.gz
abc-28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e.tar.bz2
abc-28e8e7f3e79d1391a2f3a31cefe3afe234aa3b8e.zip
Merged alanmi/abc into default
Diffstat (limited to 'src/sat/xsat/xsatUtils.h')
-rw-r--r--src/sat/xsat/xsatUtils.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/sat/xsat/xsatUtils.h b/src/sat/xsat/xsatUtils.h
new file mode 100644
index 00000000..7f774d85
--- /dev/null
+++ b/src/sat/xsat/xsatUtils.h
@@ -0,0 +1,106 @@
+/**CFile****************************************************************
+
+ FileName [xsatUtils.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [xSAT - A SAT solver written in C.
+ Read the license file for more info.]
+
+ Synopsis [Utility functions used in xSAT]
+
+ Author [Bruno Schmitt <boschmitt@inf.ufrgs.br>]
+
+ Affiliation [UC Berkeley / UFRGS]
+
+ Date [Ver. 1.0. Started - November 10, 2016.]
+
+ Revision []
+
+***********************************************************************/
+#ifndef ABC__sat__xSAT__xsatUtils_h
+#define ABC__sat__xSAT__xsatUtils_h
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+#include "misc/util/abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void xSAT_UtilSelectSort( void** pArray, int nSize, int(* CompFnct )( const void *, const void * ) )
+{
+ int i, j, iBest;
+ void* pTmp;
+
+ for ( i = 0; i < ( nSize - 1 ); i++ )
+ {
+ iBest = i;
+ for ( j = i + 1; j < nSize; j++ )
+ {
+ if ( CompFnct( pArray[j], pArray[iBest] ) )
+ iBest = j;
+ }
+ pTmp = pArray[i];
+ pArray[i] = pArray[iBest];
+ pArray[iBest] = pTmp;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static void xSAT_UtilSort( void** pArray, int nSize, int(* CompFnct )( const void *, const void *) )
+{
+ if ( nSize <= 15 )
+ xSAT_UtilSelectSort( pArray, nSize, CompFnct );
+ else
+ {
+ void* pPivot = pArray[nSize / 2];
+ void* pTmp;
+ int i = -1;
+ int j = nSize;
+
+ for(;;)
+ {
+ do i++; while( CompFnct( pArray[i], pPivot ) );
+ do j--; while( CompFnct( pPivot, pArray[j] ) );
+
+ if ( i >= j )
+ break;
+
+ pTmp = pArray[i];
+ pArray[i] = pArray[j];
+ pArray[j] = pTmp;
+ }
+
+ xSAT_UtilSort( pArray, i, CompFnct );
+ xSAT_UtilSort( pArray + i, ( nSize - i ), CompFnct );
+ }
+}
+
+ABC_NAMESPACE_HEADER_END
+
+#endif
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////