X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsn_stage.c;fp=src%2Fsn_stage.c;h=bade6c42b46a375e1525a2e1fb54403dfa129acf;hb=0f2d6e79cfef8b0db5372f832a301fee124039cb;hp=dfd3fb5e98b114d4e96e55f13496cd79a12069cc;hpb=4abd9f75fbb6d766dd97a7efd1eb70700fc48966;p=sort-networks.git diff --git a/src/sn_stage.c b/src/sn_stage.c index dfd3fb5..bade6c4 100644 --- a/src/sn_stage.c +++ b/src/sn_stage.c @@ -56,6 +56,27 @@ void sn_stage_destroy (sn_stage_t *s) free (s); } /* void sn_stage_destroy */ +int sn_stage_sort (sn_stage_t *s, int *values) +{ + sn_comparator_t *c; + int i; + + for (i = 0; i < s->comparators_num; i++) + { + c = s->comparators + i; + if (values[c->min] > values[c->max]) + { + int temp; + + temp = values[c->min]; + values[c->min] = values[c->max]; + values[c->max] = temp; + } + } + + return (0); +} /* int sn_stage_sort */ + int sn_stage_comparator_add (sn_stage_t *s, const sn_comparator_t *c) { sn_comparator_t *temp; @@ -172,7 +193,6 @@ int sn_stage_show (sn_stage_t *s) int j; int k; - for (i = 0; i < s->comparators_num; i++) { lines[i] = -1;