2 * \file sn_comparator.h
3 * \brief The sn_comparator_t class and associated methods.
6 * libsortnetwork - src/sn_comparator.h
7 * Copyright (C) 2008-2010 Florian octo Forster
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; only version 2 of the License is applicable.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * Florian octo Forster <ff at octo.it>
27 #ifndef SN_COMPARATOR_H
28 #define SN_COMPARATOR_H 1
30 struct sn_comparator_s
35 typedef struct sn_comparator_s sn_comparator_t;
37 #define SN_COMP_LEFT(c) (((c)->min < (c)->max) ? (c)->min : (c)->max)
38 #define SN_COMP_RIGHT(c) (((c)->min > (c)->max) ? (c)->min : (c)->max)
39 #define SN_COMP_MIN(c) (c)->min
40 #define SN_COMP_MAX(c) (c)->max
42 sn_comparator_t *sn_comparator_create (int min, int max);
43 void sn_comparator_destroy (sn_comparator_t *c);
44 void sn_comparator_invert (sn_comparator_t *c);
45 void sn_comparator_shift (sn_comparator_t *c, int sw, int inputs_num);
46 void sn_comparator_swap (sn_comparator_t *c, int con0, int con1);
48 int sn_comparator_compare (const void *, const void *);
50 #endif /* SN_COMPARATOR_H */
52 /* vim: set shiftwidth=2 softtabstop=2 : */