diff options
Diffstat (limited to 'sortnet.c')
-rw-r--r-- | sortnet.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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); } |