1
#ifndef __MEI_HASH_TABLE_H__
2
#define __MEI_HASH_TABLE_H__
5
* \file mei_hash_table.h
7
* \brief Hash table, intended to provide a symbol table
9
* A hash table consists of an array of container. Each container
10
* holds a copy of the key, a pointer to the data associated with the
11
* key, and a pointer to the next container that associated with this one,
16
This file is part of Code_Saturne, a general-purpose CFD tool.
18
Copyright (C) 1998-2011 EDF S.A.
20
This program is free software; you can redistribute it and/or modify it under
21
the terms of the GNU General Public License as published by the Free Software
22
Foundation; either version 2 of the License, or (at your option) any later
25
This program is distributed in the hope that it will be useful, but WITHOUT
26
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
30
You should have received a copy of the GNU General Public License along with
31
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
32
Street, Fifth Floor, Boston, MA 02110-1301, USA.
35
/*----------------------------------------------------------------------------*/
39
#endif /* __cplusplus */
41
/*============================================================================
43
*============================================================================*/
46
* \brief List of the different type of symbol
49
typedef enum { CONSTANT, ID, FUNC1, FUNC2, FUNC3, FUNC4, OPR } mei_flag_t;
51
/*============================================================================
53
*============================================================================*/
56
* \brief Type definition for a pointer to a function of one argument
59
typedef double (*func1_t) (double);
62
* \brief Type definition for pointer to a function of two arguments
65
typedef double (*func2_t) (double, double);
68
* \brief Type definition for pointer to a function of three arguments
71
typedef double (*func3_t) (double, double, double);
74
* \brief Type definition for pointer to a function of for arguments
77
typedef double (*func4_t) (double, double, double, double);
80
* \brief Type definition for data of each element contained in the hash table
84
double value; /*!< Constant or variable value. */
85
func1_t func; /*!< Pointer to function with one argument */
86
func2_t f2; /*!< Pointer to function with two argument */
90
* \brief Type definition for each bucket of the hash table
94
char *key; /*!< Pointeur to string */
95
mei_flag_t type; /*!< Constant, variable, function,... */
96
data_t *data; /*!< Data of the current bucket */
97
struct item *next; /*!< Pointer to next element */
101
* \brief Structure defining a hash table
105
int n_inter; /*!< number of interpreters associated with
106
the current table of symbols */
107
int record; /*!< number of buckets of the hash table*/
108
int length; /*!< length of the hash table */
109
struct item **table; /*!< 'table' is a list of pointers on 'item' */
113
* \brief Type definition for a hash table
116
typedef struct HashTable hash_table_t;
119
/*============================================================================
120
* Public function prototypes
121
*============================================================================*/
123
/*----------------------------------------------------------------------------
124
* Fonction qui cree une table de hachage
125
*----------------------------------------------------------------------------*/
128
void mei_hash_table_create(hash_table_t *const htable, const int modulo);
131
/*----------------------------------------------------------------------------
132
* Fonction qui initialise la table de hachage
133
*----------------------------------------------------------------------------*/
136
void mei_hash_table_init(hash_table_t *htable);
139
void mei_hash_table_dump(hash_table_t *htable);
142
void mei_hash_table_item_print(struct item *item);
145
void mei_hash_table_free(hash_table_t *htable);
148
struct item * mei_hash_table_lookup(hash_table_t *htable, const char *key);
151
void mei_hash_table_insert(hash_table_t *const htable,
152
const char *const key,
153
const mei_flag_t type,
161
struct item* mei_hash_table_find(hash_table_t *htable, const char *key);
163
/*----------------------------------------------------------------------------*/
167
#endif /* __cplusplus */
169
#endif /* __MEI_HASH_TABLE_H__ */