1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2008 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef DATA_SUBCASE_H
18 #define DATA_SUBCASE_H 1
28 enum subcase_direction
30 SC_ASCEND, /* A, B, C, ..., X, Y, Z. */
31 SC_DESCEND /* Z, Y, X, ..., C, B, A. */
34 /* A value within a case. */
37 size_t case_index; /* Starting position in the case. */
38 int width; /* 0=numeric, otherwise string width. */
39 enum subcase_direction direction; /* Sort order. */
42 /* A subcase specifies how to draw values from a case. */
45 struct subcase_field *fields;
50 void subcase_init_empty (struct subcase *);
51 void subcase_init_vars (struct subcase *,
52 const struct variable *const *, size_t n_vars);
53 void subcase_init_var (struct subcase *,
54 const struct variable *, enum subcase_direction);
55 void subcase_clone (struct subcase *, const struct subcase *);
56 void subcase_clear (struct subcase *);
57 void subcase_destroy (struct subcase *);
59 bool subcase_add_var (struct subcase *, const struct variable *,
60 enum subcase_direction);
62 static inline bool subcase_is_empty (const struct subcase *);
63 static inline size_t subcase_get_n_fields (const struct subcase *);
64 static inline size_t subcase_get_n_values (const struct subcase *);
66 static inline enum subcase_direction subcase_get_direction (
67 const struct subcase *, size_t idx);
69 bool subcase_conformable (const struct subcase *, const struct subcase *);
71 void subcase_extract (const struct subcase *, const struct ccase *,
73 void subcase_inject (const struct subcase *,
74 const union value *values, struct ccase *);
75 void subcase_copy (const struct subcase *src_sc, const struct ccase *src,
76 const struct subcase *dst_sc, struct ccase *dst);
78 int subcase_compare_3way (const struct subcase *a_sc, const struct ccase *a,
79 const struct subcase *b_sc, const struct ccase *b);
80 int subcase_compare_3way_xc (const struct subcase *,
81 const union value *a, const struct ccase *b);
82 int subcase_compare_3way_cx (const struct subcase *,
83 const struct ccase *a, const union value *b);
84 int subcase_compare_3way_xx (const struct subcase *,
85 const union value *a, const union value *b);
86 bool subcase_equal (const struct subcase *a_sc, const struct ccase *a,
87 const struct subcase *b_sc, const struct ccase *b);
88 bool subcase_equal_xc (const struct subcase *,
89 const union value *a, const struct ccase *b);
90 bool subcase_equal_cx (const struct subcase *,
91 const struct ccase *a, const union value *b);
92 bool subcase_equal_xx (const struct subcase *,
93 const union value *a, const union value *b);
95 static inline enum subcase_direction
96 subcase_get_direction (const struct subcase *sc, size_t idx)
98 return sc->fields[idx].direction;
102 subcase_is_empty (const struct subcase *sc)
104 return sc->n_fields == 0;
108 subcase_get_n_fields (const struct subcase *sc)
114 subcase_get_n_values (const struct subcase *sc)
119 #endif /* data/subcase.h */