void carcsort ( int first , int last ) { int p ; int q ; long tmp ; if ( last - first <= 1 ) { return ; } for ( p = first ; p <= last ; p ++ ) { for ( q = p ; q <= last ; q ++ ) { short pco = Cnfa . carcColor ( arcs [ p ] ) ; short qco = Cnfa . carcColor ( arcs [ q ] ) ; int pto = Cnfa . carcTarget ( arcs [ p ] ) ; int qto = Cnfa . carcTarget ( arcs [ q ] ) ; if ( pco > qco || ( pco == qco && pto > qto ) ) { assert p != q ; tmp = arcs [ p ] ; arcs [ p ] = arcs [ q ] ; arcs [ q ] = tmp ; } } } }
carcsort - sort compacted - NFA arcs by color Really dumb algorithm but if the list is long enough for that to matter you re in real trouble anyway .