841d943f48c30277ab70c6b11aada08899c4120f
[pspp-builds.git] / src / data / case-ordering.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2007 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful, but
10    WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17    02110-1301, USA. */
18
19 /* Sort order for comparing cases. */
20
21 #ifndef DATA_CASE_ORDERING_H
22 #define DATA_CASE_ORDERING_H 1
23
24 #include <stddef.h>
25 #include <data/case.h>
26
27 struct dictionary;
28
29 /* Sort direction. */
30 enum sort_direction
31   {
32     SRT_ASCEND,                 /* A, B, C, ..., X, Y, Z. */
33     SRT_DESCEND                 /* Z, Y, X, ..., C, B, A. */
34   };
35
36 /* Creation and destruction. */
37 struct case_ordering *case_ordering_create (const struct dictionary *);
38 struct case_ordering *case_ordering_clone (const struct case_ordering *);
39 void case_ordering_destroy (struct case_ordering *);
40
41 /* Modification. */
42 bool case_ordering_add_var (struct case_ordering *,
43                             const struct variable *, enum sort_direction);
44
45 /* Comparing cases. */
46 int case_ordering_compare_cases (const struct ccase *, const struct ccase *,
47                                  const struct case_ordering *);
48
49 /* Inspection. */
50 size_t case_ordering_get_value_cnt (const struct case_ordering *);
51 size_t case_ordering_get_var_cnt (const struct case_ordering *);
52 const struct variable *case_ordering_get_var (const struct case_ordering *,
53                                               size_t);
54 enum sort_direction case_ordering_get_direction (const struct case_ordering *,
55                                                  size_t);
56 void case_ordering_get_vars (const struct case_ordering *,
57                              const struct variable ***, size_t *);
58
59 #endif /* data/case-ordering.h */