summaryrefslogtreecommitdiff
path: root/sortnet.c
diff options
context:
space:
mode:
Diffstat (limited to 'sortnet.c')
-rw-r--r--sortnet.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sortnet.c b/sortnet.c
index fd99a17..40c78a8 100644
--- a/sortnet.c
+++ b/sortnet.c
@@ -2,6 +2,7 @@
#include <stdint.h>
#include "common.h"
+#include "counts.h"
static const uint8_t sortnet[][2] = {
/* 0: index = 0 */
@@ -30,9 +31,13 @@ static const uint8_t sortnet_index[] = { 0, 0, 0, 1, 4, 9, 18, 30, 46, 65 };
void sorting_network(char *base, size_t nmel, size_t width, cmpfun cmp)
{
+ struct counts snapshot = counts[CURRENT];
+
for (int i = sortnet_index[nmel]; i < sortnet_index[nmel+1]; i++) {
char *elem1 = base + sortnet[i][0] * width;
char *elem2 = base + sortnet[i][1] * width;
if (cmp(elem1, elem2) > 0) swap(elem1, elem2, width);
}
+
+ add_counts(counts + SORTNET, &snapshot);
}