summaryrefslogtreecommitdiffstats
path: root/src/misc/extra/extraUtilMisc.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2007-07-03 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2007-07-03 08:01:00 -0700
commita8db621dc96768cf2cf543be905d534579847020 (patch)
treec5c11558d1adf35b474cebd78d89b2e5ae1bc1bc /src/misc/extra/extraUtilMisc.c
parentd6804597a397379f826810a736ccbe99bf56c497 (diff)
downloadabc-a8db621dc96768cf2cf543be905d534579847020.tar.gz
abc-a8db621dc96768cf2cf543be905d534579847020.tar.bz2
abc-a8db621dc96768cf2cf543be905d534579847020.zip
Version abc70703
Diffstat (limited to 'src/misc/extra/extraUtilMisc.c')
-rw-r--r--src/misc/extra/extraUtilMisc.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/misc/extra/extraUtilMisc.c b/src/misc/extra/extraUtilMisc.c
index f62de314..dff774bc 100644
--- a/src/misc/extra/extraUtilMisc.c
+++ b/src/misc/extra/extraUtilMisc.c
@@ -2070,6 +2070,55 @@ unsigned ** Extra_Truths8()
/**Function*************************************************************
+ Synopsis [Bubble-sorts components by scores in increasing order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Extra_BubbleSort( int Order[], int Costs[], int nSize, int fIncreasing )
+{
+ int i, Temp, fChanges;
+ assert( nSize < 1000 );
+ for ( i = 0; i < nSize; i++ )
+ Order[i] = i;
+ if ( fIncreasing )
+ {
+ do {
+ fChanges = 0;
+ for ( i = 0; i < nSize - 1; i++ )
+ {
+ if ( Costs[Order[i]] <= Costs[Order[i+1]] )
+ continue;
+ Temp = Order[i];
+ Order[i] = Order[i+1];
+ Order[i+1] = Temp;
+ fChanges = 1;
+ }
+ } while ( fChanges );
+ }
+ else
+ {
+ do {
+ fChanges = 0;
+ for ( i = 0; i < nSize - 1; i++ )
+ {
+ if ( Costs[Order[i]] >= Costs[Order[i+1]] )
+ continue;
+ Temp = Order[i];
+ Order[i] = Order[i+1];
+ Order[i+1] = Temp;
+ fChanges = 1;
+ }
+ } while ( fChanges );
+ }
+}
+
+/**Function*************************************************************
+
Synopsis [Returns the smallest prime larger than the number.]
Description []
@@ -2104,7 +2153,6 @@ unsigned int Cudd_PrimeCopy( unsigned int p)
} /* end of Cudd_Prime */
-
/*---------------------------------------------------------------------------*/
/* Definition of internal functions */
/*---------------------------------------------------------------------------*/