1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /*                                                                           */
3 /*   File....: hash.h                                                        */
4 /*   Name....: Hash Functions                                                */
5 /*   Author..: Thorsten Koch                                                 */
6 /*   Copyright by Author, All rights reserved                                */
7 /*                                                                           */
8 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
9 /*
10  * Copyright (C) 2001-2018 by Thorsten Koch <koch@zib.de>
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public License
14  * as published by the Free Software Foundation; either version 3
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
25  */
26 #ifndef _HASH_H_
27 #define _HASH_H_
28 
29 #ifndef _NUMB_H_
30 #error "Need to include numb.h before hash.h"
31 #endif
32 #ifndef _ELEM_H_
33 #error "Need to include elem.h before hash.h"
34 #endif
35 #ifndef _TUPLE_H_
36 #error "Need to include tuple.h before hash.h"
37 #endif
38 #ifndef _MME_H_
39 #error "Need to include mme.h before hash.h (Entry,Mono)"
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 enum hash_type       { HASH_ERR = 0, HASH_TUPLE, HASH_ENTRY, HASH_ELEM_IDX, HASH_NUMB, HASH_MONO };
47 
48 typedef enum hash_type           HashType;
49 typedef struct hash              Hash;
50 
51 /*lint -sem(        hash_new, chneg(2), @P >= malloc(1)) */
52 extern Hash*        hash_new(HashType type, int size);
53 /*lint -sem(        hash_free, custodial(1), cleanup, inout(1), 1P) */
54 extern void         hash_free(Hash* hash);
55 /*lint -sem(        hash_add_tuple, inout(1), 1P >= 1, 2P >= 1) */
56 extern void         hash_add_tuple(Hash* hash, const Tuple* tuple);
57 /*lint -sem(        hash_add_entry, inout(1), 1P >= 1, 2P >= 1) */
58 extern void         hash_add_entry(Hash* hash, const Entry* entry);
59 /*lint -sem(        hash_add_mono, inout(1), 1P >= 1, 2P >= 1) */
60 extern void         hash_add_mono(Hash* hash, const Mono* mono);
61 /*lint -sem(        hash_add_elem_idx, inout(1), 1P >= 1, 2p, chneg(3)) */
62 extern void         hash_add_elem_idx(Hash* hash, const Elem* elem, int idx);
63 /*lint -sem(        hash_add_numb, inout(1), 1P >= 1, 2P >= 1) */
64 extern void         hash_add_numb(Hash* hash, const Numb* numb);
65 /*lint -sem(        hash_has_tuple, pure, 1P >= 1, 2P >= 1) */
66 extern bool         hash_has_tuple(const Hash* hash, const Tuple* tuple);
67 /*lint -sem(        hash_has_entry, pure, 1P >= 1, 2P >= 1) */
68 extern bool         hash_has_entry(const Hash* hash, const Tuple* tuple);
69 /*lint -sem(        hash_has_numb, pure, 1P >= 1, 2P >= 1) */
70 extern bool         hash_has_numb(const Hash* hash, const Numb* numb);
71 /*lint -sem(        hash_lookup_entry, pure, 1P >= 1, 2P >= 1) */
72 extern const Entry* hash_lookup_entry(const Hash* hash, const Tuple* tuple);
73 /*lint -sem(        hash_lookup_mono, pure, 1P >= 1, 2P >= 1) */
74 extern const Mono*  hash_lookup_mono(const Hash* hash, const Mono* mono);
75 /*lint -sem(        hash_lookup_elem_idx, pure, 1P >= 1, 2P >= 1) */
76 extern int          hash_lookup_elem_idx(const Hash* hash, const Elem* elem);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 #endif /* _HASH_H_ */
82