From: Florian Forster Date: Thu, 20 Nov 2008 08:43:04 +0000 (+0100) Subject: src/sn_comparator.[ch]: Implement `sn_comparator_shift'. X-Git-Tag: v1.0.0~88 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=046949571659a4f418cd40ac871ac1c4a3535097;p=sort-networks.git src/sn_comparator.[ch]: Implement `sn_comparator_shift'. --- diff --git a/src/sn_comparator.c b/src/sn_comparator.c index 052731c..e9753dc 100644 --- a/src/sn_comparator.c +++ b/src/sn_comparator.c @@ -61,6 +61,12 @@ void sn_comparator_invert (sn_comparator_t *c) c->max = max; } /* void sn_comparator_invert */ +void sn_comparator_shift (sn_comparator_t *c, int sw, int inputs_num) +{ + c->min = (c->min + sw) % inputs_num; + c->max = (c->max + sw) % inputs_num; +} /* void sn_comparator_shift */ + void sn_comparator_swap (sn_comparator_t *c, int con0, int con1) { if (c->min == con0) diff --git a/src/sn_comparator.h b/src/sn_comparator.h index e5bb3dd..a2d34d7 100644 --- a/src/sn_comparator.h +++ b/src/sn_comparator.h @@ -37,6 +37,7 @@ typedef struct sn_comparator_s sn_comparator_t; sn_comparator_t *sn_comparator_create (int min, int max); void sn_comparator_destroy (sn_comparator_t *c); void sn_comparator_invert (sn_comparator_t *c); +void sn_comparator_shift (sn_comparator_t *c, int sw, int inputs_num); void sn_comparator_swap (sn_comparator_t *c, int con0, int con1); int sn_comparator_compare (const void *, const void *);