1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
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.
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.
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
25 typedef int hsh_compare_func (const void *, const void *, const void *aux);
26 typedef unsigned hsh_hash_func (const void *, const void *aux);
27 typedef void hsh_free_func (void *, const void *aux);
29 /* Hash table iterator (opaque). */
32 size_t next; /* Index of next entry. */
36 unsigned hsh_hash_bytes (const void *, size_t);
37 unsigned hsh_hash_string (const char *);
38 unsigned hsh_hash_case_string (const char *);
39 unsigned hsh_hash_int (int);
40 unsigned hsh_hash_double (double);
43 struct hsh_table *hsh_create (int m, hsh_compare_func *,
44 hsh_hash_func *, hsh_free_func *,
48 struct hsh_table *hsh_create_pool (struct pool *pool, int m,
50 hsh_hash_func *, hsh_free_func *,
53 void hsh_clear (struct hsh_table *);
54 void hsh_destroy (struct hsh_table *);
55 void *const *hsh_sort (struct hsh_table *);
56 void *const *hsh_data (struct hsh_table *);
57 void **hsh_sort_copy (struct hsh_table *);
58 void **hsh_data_copy (struct hsh_table *);
60 /* Search and insertion. */
61 void **hsh_probe (struct hsh_table *, const void *);
62 void *hsh_insert (struct hsh_table *, void *);
63 void *hsh_replace (struct hsh_table *, void *);
64 void *hsh_find (struct hsh_table *, const void *);
65 bool hsh_delete (struct hsh_table *, const void *);
68 void *hsh_first (struct hsh_table *, struct hsh_iterator *);
69 void *hsh_next (struct hsh_table *, struct hsh_iterator *);
71 /* Search and insertion with assertion. */
73 void hsh_force_insert (struct hsh_table *, void *);
74 void *hsh_force_find (struct hsh_table *, const void *);
75 void hsh_force_delete (struct hsh_table *, const void *);
77 #define hsh_force_insert(A, B) ((void) (*hsh_probe (A, B) = B))
78 #define hsh_force_find(A, B) (hsh_find (A, B))
79 #define hsh_force_delete(A, B) ((void) hsh_delete (A, B))
82 /* Number of entries in hash table H. */
83 size_t hsh_count (struct hsh_table *);
87 void hsh_dump (struct hsh_table *);