Implemented the NPAR TESTS command.
[pspp-builds.git] / src / language / stats / freq.c
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3    Written by John Darrington <john@darrington.wattle.id.au>
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #include <config.h>
21 #include <data/variable.h>
22 #include <data/value.h>
23 #include <libpspp/compiler.h>
24
25 #include <stdlib.h>
26
27 #include "freq.h"
28
29 int 
30 compare_freq ( const void *_f1, const void *_f2, const void *_var)
31 {
32   const struct freq *f1 = _f1;
33   const struct freq *f2 = _f2;
34   const struct variable *var = _var;
35
36   return  compare_values (f1->value, f2->value, var_get_width (var) );
37 }
38
39 unsigned int
40 hash_freq (const void *_f, const void *_var)
41 {
42   const struct freq *f = _f;
43   const struct variable *var  = _var;
44
45   return hash_value (f->value, var_get_width (var));
46 }
47
48 /* Free function to be used on FR whose value parameter has been copied */
49 void 
50 free_freq_mutable_hash (void *fr, const void *var UNUSED)
51 {
52   struct freq_mutable *freq = fr;
53   free (freq->value);
54   free (freq);
55 }
56
57 void 
58 free_freq_hash (void *fr, const void *var UNUSED)
59 {
60   free (fr);
61 }