Loading...
Searching...
No Matches
htable.h File Reference
Hash tables

Hash tables templates. More...

Go to the source code of this file.

## Macros

#define | HTABLE_H
| Defined when <sofia-sip/htable.h> has been included.
#define | HTABLE_MIN_SIZE
| Minimum size of hash table.
#define | HTABLE_DECLARE(prefix, pr, entry_t)
| Declare hash table structure type.
#define | HTABLE_SCOPE
| Default scope for hash table functions.
#define | HTABLE_PROTOS(prefix, pr, entry_t)
| Prototypes for hash table.
#define | HTABLE_BODIES(prefix, pr, entry_t, hfun)
| Hash table implementation.

## Detailed Description

Hash tables templates.

This file contain a hash table template for C. The hash tables are resizeable, and they usually contain pointers to entries. The declaration for template datatypes is instantiated with macro HTABLE_DECLARE(). The prototypes for hashing functions are instantiated with macro HTABLE_PROTOS(). The implementation is instantiated with macro HTABLE_BODIES().

The hash table template is most efficient when the hash value is precalculated and stored in each entry. The hash "function" given to the HTABLE_BODIES() would then be something like macro

#define HTABLE_ENTRY_HASH(e) ((e)->e_hash_value)

When a entry with new identical hash key is added to the table, it can be either inserted (before any other entry with same key value) or appended.

Example code can be found from <htable_test.c>.

Author
  Pekka Pessi Pekka.nosp@m..Pes.nosp@m.si@no.nosp@m.kia..nosp@m.com

Date
  Created: Tue Sep 25 17:42:40 2001 ppessi

## Macro Definition Documentation

## HTABLE_BODIES

#define HTABLE_BODIES | ( |  | prefix,
|  |  | pr,
|  |  | entry_t,
|  |  | hfun )

Hash table implementation.

The macro HTABLE_BODIES() expands the hash table functions. The function and type names start with prefix, the field names start with pr. The entry type is entry_t. The function (or macro) name returning hash value of each entry is given as hfun.

Parameters

  prefix | hash table type and function prefix
  pr | hash table field prefix
  entry_t | entry type
  hfun | function or macro returning hash value of entry

## HTABLE_DECLARE

#define HTABLE_DECLARE | ( |  | prefix,
|  |  | pr,
|  |  | entry_t )

Declare hash table structure type.

The macro HTABLE_DECLARE() expands to a declaration for hash table structure. The its typedef will be prefix`_t`, the field names start withb pr. The entry type is entry_t.

Parameters

  prefix | hash table type and function prefix
  pr | hash table field prefix
  entry_t | entry type

## HTABLE_PROTOS

#define HTABLE_PROTOS | ( |  | prefix,
|  |  | pr,
|  |  | entry_t )

Prototypes for hash table.

The macro HTABLE_PROTOS() expands to the prototypes of hash table functions. The function and type names start with prefix, the field names start with pr. The entry type is entry_t.

Parameters

  prefix | hash table type and function prefix
  pr | hash table field prefix
  entry_t | entry type

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.