Imported the initial C files that make up a decent sorting network toolkit already.
[sort-networks.git] / src / sn_stage.h
1 #ifndef SN_STAGE_H
2 #define SN_STAGE_H 1
3
4 #include <stdio.h>
5
6 #include "sn_comparator.h"
7
8 struct sn_stage_s
9 {
10   int depth;
11   sn_comparator_t *comparators;
12   int comparators_num;
13 };
14 typedef struct sn_stage_s sn_stage_t;
15
16 enum sn_network_cut_dir_e
17 {
18   DIR_MIN,
19   DIR_MAX
20 };
21
22 #define SN_STAGE_DEPTH(s) (s)->depth
23 #define SN_STAGE_COMP_NUM(s) (s)->comparators_num
24 #define SN_STAGE_COMP_GET(s,n) ((s)->comparators + (n))
25
26 sn_stage_t *sn_stage_create (int depth);
27 void sn_stage_destroy (sn_stage_t *s);
28
29 int sn_stage_comparator_add (sn_stage_t *s, const sn_comparator_t *c);
30 int sn_stage_comparator_remove (sn_stage_t *s, int c_num);
31 int sn_stage_comparator_check_conflict (sn_stage_t *s, const sn_comparator_t *c);
32
33 int sn_stage_show (sn_stage_t *s);
34 int sn_stage_invert (sn_stage_t *s);
35 int sn_stage_swap (sn_stage_t *s, int con0, int con1);
36 int sn_stage_cut_at (sn_stage_t *s, int input, enum sn_network_cut_dir_e dir);
37 int sn_stage_remove_input (sn_stage_t *s, int input);
38
39 sn_stage_t *sn_stage_read (FILE *fh);
40 int sn_stage_write (sn_stage_t *s, FILE *fh);
41
42 #endif /* SN_STAGE_H */
43
44 /* vim: set shiftwidth=2 softtabstop=2 : */