src/sn_comparator.[ch]: Implement `sn_comparator_shift'.
[sort-networks.git] / src / sn-apply.c
index 4793097..3694f03 100644 (file)
  *   Florian octo Forster <octo at verplant.org>
  **/
 
-#define _ISOC99_SOURCE
-#define _POSIX_C_SOURCE 200112L
+#ifndef _ISOC99_SOURCE
+# define _ISOC99_SOURCE
+#endif
+#ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -138,23 +142,9 @@ static int show_sort (int *values)
   for (i = 0; i < stages_num; i++)
   {
     sn_stage_t *s;
-    int j;
 
     s = SN_NETWORK_STAGE_GET (network, i);
-
-    for (j = 0; j < SN_STAGE_COMP_NUM (s); j++)
-    {
-      sn_comparator_t *c;
-
-      c = SN_STAGE_COMP_GET (s, j);
-
-      if (values[c->min] > values[c->max])
-      {
-       int temp = values[c->min];
-       values[c->min] = values[c->max];
-       values[c->max] = temp;
-      }
-    } /* for (comparators) */
+    sn_stage_sort (s, values);
 
     show_values (SN_NETWORK_INPUT_NUM (network), values);
   } /* for (stages) */