Defines

sofia-sip/htable2.h File Reference

Hash tables templates, take 2. More...

Go to the source code of this file.

Defines

#define HTABLE2_H
 Defined when <sofia-sip/htable2.h> has been included.
#define HTABLE2_MIN_SIZE
 Minimum size of hash table.
#define HTABLE2_DECLARE2(type, sname, pr, entrytype, sizetype)
 Declare hash table structure type.
#define HTABLE2_SCOPE
 Default scope for hash table functions.
#define HTABLE2_PROTOS2(type, prefix, pr, entrytype, sizetype)
 Prototypes for hash table.
#define HTABLE2_BODIES2(type, prefix, pr, entrytype, sizetype,hfun, is_used, reclaim, is_equal, halloc)
 Hash table implementation.

Detailed Description

Hash tables templates, take 2.

Note: this version stores the given element types as entries (instead of always storing a pointer to element). It can be used without <sofia-sip/su_alloc.h>.

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 HTABLE2_DECLARE2(). The prototypes for hashing functions are instantiated with macro HTABLE2_PROTOS2(). The implementation is instantiated with macro HTABLE2_BODIES2().

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

 #define ENTRY_HASH(e) ((e).e_hash_value)

When a entry with new identical 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.Pessi@nokia-email.address.hidden>.
Date:
Created: Tue Sep 25 17:42:40 2001 ppessi

Define Documentation

#define HTABLE2_BODIES2 (   type,
  prefix,
  pr,
  entrytype,
  sizetype,
  hfun,
  is_used,
  reclaim,
  is_equal,
  halloc 
)

Hash table implementation.

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

Parameters:
type hash table type
prefix function prefix for hash table
pr field prefix for hash table
entrytype type of entry element
sizetype size_t type
hfun function or macro returning hash value of entry
is_used function or macro returning true if entry is occupied
reclaim function or macro zeroing entry
is_equal equality test
halloc function allocating or freeing memory
Since:
New in 1.12.8
#define HTABLE2_DECLARE2 (   type,
  sname,
  pr,
  entrytype,
  sizetype 
)

Declare hash table structure type.

The macro HTABLE2_DECLARE2() expands to a declaration for hash table structure. The its typedef will be type, the field names start with pr. The entry type is entrytype.

Parameters:
type hash table typedef
sname name of struct
pr hash table field prefix
entrytype entry type
sizetype type of size variables
Since:
New in 1.12.8
#define HTABLE2_H

Defined when <sofia-sip/htable2.h> has been included.

#define HTABLE2_PROTOS2 (   type,
  prefix,
  pr,
  entrytype,
  sizetype 
)

Prototypes for hash table.

The macro HTABLE2_PROTOS2() 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 entrytype.

Parameters:
type hash table typedef
prefix function prefix
pr hash table field prefix (not used)
entrytype entry type
sizetype type of size variables
Since:
New in 1.12.8
#define HTABLE2_SCOPE

Default scope for hash table functions.

 All Data Structures Files Functions Variables Typedefs Enumerator Defines

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