Hash Tables


マクロ定義

#define APR_HASH_KEY_STRING   (-1)

型定義

typedef apr_hash_t apr_hash_t
typedef apr_hash_index_t apr_hash_index_t
typedef unsigned int(*) apr_hashfunc_t (const char *key, apr_ssize_t *klen)

関数

unsigned int apr_hashfunc_default (const char *key, apr_ssize_t *klen)
apr_hash_tapr_hash_make (apr_pool_t *pool)
apr_hash_tapr_hash_make_custom (apr_pool_t *pool, apr_hashfunc_t hash_func)
apr_hash_tapr_hash_copy (apr_pool_t *pool, const apr_hash_t *h)
void apr_hash_set (apr_hash_t *ht, const void *key, apr_ssize_t klen, const void *val)
void * apr_hash_get (apr_hash_t *ht, const void *key, apr_ssize_t klen)
apr_hash_index_tapr_hash_first (apr_pool_t *p, apr_hash_t *ht)
apr_hash_index_tapr_hash_next (apr_hash_index_t *hi)
void apr_hash_this (apr_hash_index_t *hi, const void **key, apr_ssize_t *klen, void **val)
unsigned int apr_hash_count (apr_hash_t *ht)
apr_hash_tapr_hash_overlay (apr_pool_t *p, const apr_hash_t *overlay, const apr_hash_t *base)
apr_hash_tapr_hash_merge (apr_pool_t *p, const apr_hash_t *h1, const apr_hash_t *h2, void *(*merger)(apr_pool_t *p, const void *key, apr_ssize_t klen, const void *h1_val, const void *h2_val, const void *data), const void *data)
apr_pool_tapr_hash_pool_get (const apr_hash_t *thehash)

マクロ定義

#define APR_HASH_KEY_STRING   (-1)

When passing a key to apr_hash_set or apr_hash_get, this value can be passed to indicate a string-valued key, and have apr_hash compute the length automatically.

意見:
apr_hash will use strlen(key) for the length. The NUL terminator is not included in the hash value (why throw a constant in?). Since the hash table merely references the provided key (rather than copying it), apr_hash_this() will return the NUL-term'd key.


型定義

typedef struct apr_hash_index_t apr_hash_index_t

Abstract type for scanning hash tables.

typedef struct apr_hash_t apr_hash_t

Abstract type for hash tables.

typedef unsigned int(*) apr_hashfunc_t(const char *key, apr_ssize_t *klen)

Callback functions for calculating hash values.

引数:
key The key.
klen The length of the key, or APR_HASH_KEY_STRING to use the string length. If APR_HASH_KEY_STRING then returns the actual key length.


関数

apr_hash_t* apr_hash_copy ( apr_pool_t pool,
const apr_hash_t h 
)

Make a copy of a hash table

引数:
pool The pool from which to allocate the new hash table
h The hash table to clone
戻り値:
The hash table just created
意見:
Makes a shallow copy

unsigned int apr_hash_count ( apr_hash_t ht  ) 

Get the number of key/value pairs in the hash table.

引数:
ht The hash table
戻り値:
The number of key/value pairs in the hash table.

apr_hash_index_t* apr_hash_first ( apr_pool_t p,
apr_hash_t ht 
)

 int sum_values(apr_pool_t *p, apr_hash_t *ht)
 {
     apr_hash_index_t *hi;
     void *val;
     int sum = 0;
     for (hi = apr_hash_first(p, ht); hi; hi = apr_hash_next(hi)) {
         apr_hash_this(hi, NULL, NULL, &val);
         sum += *(int *)val;
     }
     return sum;
 }
 

void* apr_hash_get ( apr_hash_t ht,
const void *  key,
apr_ssize_t  klen 
)

Look up the value associated with a key in a hash table.

引数:
ht The hash table
key Pointer to the key
klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length.
戻り値:
Returns NULL if the key is not present.

apr_hash_t* apr_hash_make ( apr_pool_t pool  ) 

Create a hash table.

引数:
pool The pool to allocate the hash table out of
戻り値:
The hash table just created

apr_hash_t* apr_hash_make_custom ( apr_pool_t pool,
apr_hashfunc_t  hash_func 
)

Create a hash table with a custom hash function

引数:
pool The pool to allocate the hash table out of
hash_func A custom hash function.
戻り値:
The hash table just created

apr_hash_t* apr_hash_merge ( apr_pool_t p,
const apr_hash_t h1,
const apr_hash_t h2,
void *(*)(apr_pool_t *p, const void *key, apr_ssize_t klen, const void *h1_val, const void *h2_val, const void *data)  merger,
const void *  data 
)

Merge two hash tables into one new hash table. If the same key is present in both tables, call the supplied merge function to produce a merged value for the key in the new table. Both hash tables must use the same hash function.

引数:
p The pool to use for the new hash table
h1 The first of the tables to merge
h2 The second of the tables to merge
merger A callback function to merge values, or NULL to make values from h1 override values from h2 (same semantics as apr_hash_overlay())
data Client data to pass to the merger function
戻り値:
A new hash table containing all of the data from the two passed in

apr_hash_index_t* apr_hash_next ( apr_hash_index_t hi  ) 

Continue iterating over the entries in a hash table.

引数:
hi The iteration state
戻り値:
a pointer to the updated iteration state. NULL if there are no more entries.

apr_hash_t* apr_hash_overlay ( apr_pool_t p,
const apr_hash_t overlay,
const apr_hash_t base 
)

Merge two hash tables into one new hash table. The values of the overlay hash override the values of the base if both have the same key. Both hash tables must use the same hash function.

引数:
p The pool to use for the new hash table
overlay The table to add to the initial table
base The table that represents the initial values of the new table
戻り値:
A new hash table containing all of the data from the two passed in

apr_pool_t* apr_hash_pool_get ( const apr_hash_t thehash  ) 

Get a pointer to the pool which the hash table was created in

void apr_hash_set ( apr_hash_t ht,
const void *  key,
apr_ssize_t  klen,
const void *  val 
)

Associate a value with a key in a hash table.

引数:
ht The hash table
key Pointer to the key
klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length.
val Value to associate with the key
意見:
If the value is NULL the hash entry is deleted.

void apr_hash_this ( apr_hash_index_t hi,
const void **  key,
apr_ssize_t *  klen,
void **  val 
)

Get the current entry's details from the iteration state.

引数:
hi The iteration state
key Return pointer for the pointer to the key.
klen Return pointer for the key length.
val Return pointer for the associated value.
意見:
The return pointers should point to a variable that will be set to the corresponding data, or they may be NULL if the data isn't interesting.

unsigned int apr_hashfunc_default ( const char *  key,
apr_ssize_t *  klen 
)

The default hash function.


Apache Portable Runtimeに対してSun Jul 19 22:04:01 2009に生成されました。  doxygen 1.4.7