ftwin 0.8.10
napr_hash.h
Go to the documentation of this file.
1
6/*
7 * Copyright (C) 2007 François Pesce : francois.pesce (at) gmail (dot) com
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22#ifndef NAPR_HASH_H
23#define NAPR_HASH_H
24
25#include <apr.h>
26#include <apr_pools.h>
27
31typedef struct napr_hash_t napr_hash_t;
32
37
43typedef const void *(get_key_callback_fn_t) (const void *);
44
50typedef apr_size_t (get_key_len_callback_fn_t) (const void *);
51
60typedef int (key_cmp_callback_fn_t) (const void *, const void *, apr_size_t);
61
68typedef apr_uint32_t (hash_callback_fn_t) (register const void *, register apr_size_t);
69
81napr_hash_t *napr_hash_make(apr_pool_t *pool, apr_size_t nel, apr_size_t ffactor, get_key_callback_fn_t get_key,
83
91napr_hash_t *napr_hash_str_make(apr_pool_t *pool, apr_size_t nel, apr_size_t ffactor);
92
102void *napr_hash_search(napr_hash_t *hash, const void *key, apr_size_t key_len, apr_uint32_t *hash_value);
103
110void napr_hash_remove(napr_hash_t *hash, void *data, apr_uint32_t hash_value);
111
119apr_status_t napr_hash_set(napr_hash_t *hash, void *data, apr_uint32_t hash_value);
120
126apr_pool_t *napr_hash_pool_get(const napr_hash_t *thehash);
127
144napr_hash_index_t *napr_hash_first(apr_pool_t *pool, napr_hash_t *hash);
145
152
160void napr_hash_this(napr_hash_index_t *hi, const void **key, apr_size_t *klen, void **val);
161
162#endif /* NAPR_HASH_H */
int() key_cmp_callback_fn_t(const void *, const void *, apr_size_t)
Callback function to compare two keys.
Definition napr_hash.h:60
apr_pool_t * napr_hash_pool_get(const napr_hash_t *thehash)
Get a pointer to the pool from which the hash table was allocated.
Definition napr_hash.c:275
napr_hash_index_t * napr_hash_first(apr_pool_t *pool, napr_hash_t *hash)
Start iterating over the entries in a hash table.
Definition napr_hash.c:280
struct napr_hash_index_t napr_hash_index_t
Opaque hash table iterator structure.
Definition napr_hash.h:36
void napr_hash_this(napr_hash_index_t *hi, const void **key, apr_size_t *klen, void **val)
Get the current entry's details from the iteration state.
Definition napr_hash.c:314
apr_uint32_t() hash_callback_fn_t(register const void *, register apr_size_t)
Callback function to compute the hash value of a key.
Definition napr_hash.h:68
napr_hash_t * napr_hash_str_make(apr_pool_t *pool, apr_size_t nel, apr_size_t ffactor)
Create a hash table optimized for storing C strings as keys.
Definition napr_hash.c:95
apr_status_t napr_hash_set(napr_hash_t *hash, void *data, apr_uint32_t hash_value)
Inserts or updates an item in the hash table.
Definition napr_hash.c:242
void * napr_hash_search(napr_hash_t *hash, const void *key, apr_size_t key_len, apr_uint32_t *hash_value)
Searches the hash table for an item.
Definition napr_hash.c:145
napr_hash_index_t * napr_hash_next(napr_hash_index_t *index)
Continue iterating over the entries in a hash table.
Definition napr_hash.c:294
apr_size_t() get_key_len_callback_fn_t(const void *)
Callback function to get the length of a key.
Definition napr_hash.h:50
const void *() get_key_callback_fn_t(const void *)
Callback function to extract the key from a stored data item.
Definition napr_hash.h:43
struct napr_hash_t napr_hash_t
Opaque hash table structure.
Definition napr_hash.h:31
void napr_hash_remove(napr_hash_t *hash, void *data, apr_uint32_t hash_value)
Removes an item from the hash table.
Definition napr_hash.c:210
napr_hash_t * napr_hash_make(apr_pool_t *pool, apr_size_t nel, apr_size_t ffactor, get_key_callback_fn_t get_key, get_key_len_callback_fn_t get_key_len, key_cmp_callback_fn_t key_cmp, hash_callback_fn_t hash)
Create a hash table with custom key handling and hashing functions.
Definition napr_hash.c:100