src/mei/mei_hash_table.h File Reference

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Enumerations | Functions
mei_hash_table.h File Reference

Hash table, intended to provide a symbol table. More...

Go to the source code of this file.

## Data Structures
union | data_t
| Type definition for data of each element contained in the hash table. More...
struct | item
| Type definition for each record of the hash table. More...
struct | hash_table_t
| Structure defining a hash table. More...

## Typedefs
typedef double(* | func1_t )(double)
| Type definition for a pointer to a function of one argument. More...
typedef double(* | func2_t )(double, double)
| Type definition for pointer to a function of two arguments. More...
typedef double(* | func3_t )(double, double, double)
| Type definition for pointer to a function of three arguments. More...
typedef double(* | func4_t )(double, double, double, double)
| Type definition for pointer to a function of for arguments. More...
typedef double(* | interp1d_t )(char *, int, int, double)
| Type definition for pointer to a function of for 1D interpolation. More...

## Enumerations
enum | mei_flag_t { CONSTANT, ID, FUNC1, FUNC2, FUNC3, FUNC4, INTERP1D, OPR }
| List of the different type of symbol. More...

## Functions
void | mei_hash_table_create (hash_table_t *const htable, const int modulo)
| Initialize the hash table to the size (modulo) asked for. Allocates space for the correct number of pointers and sets them to NULL. More...
void | mei_hash_table_init (hash_table_t *htable)
| Initialize the hash table with default symbols. More...
void | mei_hash_table_free (hash_table_t *htable)
| Destroy a hash table. More...
struct item * | mei_hash_table_lookup (hash_table_t *htable, const char *key)
| Find a record in a hash table. More...
void | mei_hash_table_insert (hash_table_t *const htable, const char *const key, const mei_flag_t type, const double value, const func1_t func, const func2_t f2, const func3_t f3, const func4_t f4, const interp1d_t i1d)
| Insert a record in a hash table. More...
struct item * | mei_hash_table_find (hash_table_t *htable, const char *key)
| Find a record in a hash table. More...
void | mei_hash_table_dump (hash_table_t *htable)
| Dump of table contents for debuging purpose. More...
void | mei_hash_table_item_print (struct item *item)
| Dump function of a single record. More...

## Detailed Description

Hash table, intended to provide a symbol table.

A hash table consists of an array of container. Each container holds a copy of the key, a pointer to the data associated with the key, and a pointer to the next container that associated with this one, if there was one.

## Typedef Documentation

typedef double(* func1_t)(double)

Type definition for a pointer to a function of one argument.

typedef double(* func2_t)(double, double)

Type definition for pointer to a function of two arguments.

typedef double(* func3_t)(double, double, double)

Type definition for pointer to a function of three arguments.

typedef double(* func4_t)(double, double, double, double)

Type definition for pointer to a function of for arguments.

typedef double(* interp1d_t)(char *, int, int, double)

Type definition for pointer to a function of for 1D interpolation.

## Enumeration Type Documentation

enum mei_flag_t

List of the different type of symbol.

Enumerator
CONSTANT |
ID |
FUNC1 |
FUNC2 |
FUNC3 |
FUNC4 |
INTERP1D |
OPR |

## Function Documentation

void mei_hash_table_create | ( | hash_table_t *const | htable,
|  | const int | modulo
| ) |  |

Initialize the hash table to the size (modulo) asked for. Allocates space for the correct number of pointers and sets them to NULL.

Parameters

  [in] | htable | hash table
  [in] | modulo | size of the hash table

void mei_hash_table_dump | ( | hash_table_t *const | htable | ) |

Dump of table contents for debuging purpose.

Parameters

  [in] | htable | hash table

struct item* mei_hash_table_find | ( | hash_table_t *const | htable,
|  | const char *const | key
| ) |  |
| read

Find a record in a hash table.

Parameters

  [in] | htable | hash table
  [in] | key | key

Returns
  a pointer containing the record

void mei_hash_table_free | ( | hash_table_t *const | htable | ) |

Destroy a hash table.

Parameters

  [in] | htable | hash table

void mei_hash_table_init | ( | hash_table_t *const | htable | ) |

Initialize the hash table with default symbols.

Parameters

  [in] | htable | hash table

void mei_hash_table_insert | ( | hash_table_t *const | htable,
|  | const char *const | key,
|  | const mei_flag_t | type,
|  | const double | value,
|  | const func1_t | f1,
|  | const func2_t | f2,
|  | const func3_t | f3,
|  | const func4_t | f4,
|  | const interp1d_t | i1d
| ) |  |

Insert a record in a hash table.

Parameters

  [in] | htable | hash table
  [in] | key | key associated to the record
  [in] | type | flag associated to the record
  [in] | value | store a value if the record if a real
  [in] | f1 | pointer on a one argument function
  [in] | f2 | pointer on a two argument function
  [in] | f3 | pointer on a three argument function
  [in] | f4 | pointer on a four argument function
  [in] | i1d | pointer on a 1D interpolation function

void mei_hash_table_item_print | ( | struct item * | item | ) |

Dump function of a single record.

Parameters

  [in] | item | record

struct item* mei_hash_table_lookup | ( | hash_table_t *const | htable,
|  | const char *const | key
| ) |  |
| read

Find a record in a hash table.

Parameters

  [in] | htable | hash table
  [in] | key | key

Returns
  a pointer containing the record