-/****h* silcutil/silchashtable.h
- *
- * NAME
- *
- * silchashtable.h
- *
- * COPYRIGHT
- *
- * Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
- *
- * Copyright (C) 2001 Pekka Riikonen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+/*
+
+ silchashtable.h
+
+ Author: Pekka Riikonen <priikone@silcnet.org>
+
+ Copyright (C) 2001 - 2002 Pekka Riikonen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+*/
+
+/****h* silcutil/SilcHashTableAPI
*
* DESCRIPTION
*
* silc_hash_table_list(hash_table, &htl);
* while (silc_hash_table_get(&htl, (void *)&key, (void *)&context))
* ...
+ * silc_hash_table_list_reset(&htl);
*
* SOURCE
*/
struct SilcHashTableListStruct {
SilcHashTable ht;
void *entry;
- uint32 index;
+ SilcUInt32 index;
+ bool auto_rehash;
};
/***/
*
* SYNOPSIS
*
- * typedef uint32 (*SilcHashFunction)(void *key, void *user_context);
+ * typedef SilcUInt32 (*SilcHashFunction)(void *key, void *user_context);
*
* DESCRIPTION
*
* to the callback.
*
***/
-typedef uint32 (*SilcHashFunction)(void *key, void *user_context);
+typedef SilcUInt32 (*SilcHashFunction)(void *key, void *user_context);
/****f* silcutil/SilcHashTableAPI/SilcHashCompare
*
*
* SYNOPSIS
*
- * SilcHashTable silc_hash_table_alloc(uint32 table_size,
+ * SilcHashTable silc_hash_table_alloc(SilcUInt32 table_size,
* SilcHashFunction hash,
* void *hash_user_context,
* SilcHashCompare compare,
* are optional.
*
***/
-SilcHashTable silc_hash_table_alloc(uint32 table_size,
+SilcHashTable silc_hash_table_alloc(SilcUInt32 table_size,
SilcHashFunction hash,
void *hash_user_context,
SilcHashCompare compare,
*
* SYNOPSIS
*
- * uint32 silc_hash_table_size(SilcHashTable ht);
+ * SilcUInt32 silc_hash_table_size(SilcHashTable ht);
*
* DESCRIPTION
*
* hash table.
*
***/
-uint32 silc_hash_table_size(SilcHashTable ht);
+SilcUInt32 silc_hash_table_size(SilcHashTable ht);
/****f* silcutil/SilcHashTableAPI/silc_hash_table_count
*
* SYNOPSIS
*
- * uint32 silc_hash_table_count(SilcHashTable ht);
+ * SilcUInt32 silc_hash_table_count(SilcHashTable ht);
*
* DESCRIPTION
*
* silc_hash_table_rehash is recommended.
*
***/
-uint32 silc_hash_table_count(SilcHashTable ht);
+SilcUInt32 silc_hash_table_count(SilcHashTable ht);
/****f* silcutil/SilcHashTableAPI/silc_hash_table_add
*
* DESCRIPTION
*
* Same as silc_hash_table_add but if the `key' already exists in the
- * hash table the old key and the old context will be replace with the
+ * hash table the old key and the old context will be replaced with the
* `key' and the `context. The destructor function will be called for the
* replaced key and context.
*
* and contexts from the hash table that are found using the `key'. The
* `foreach' is called for every found key.
*
+ * NOTES
+ *
+ * The hash table will not be rehashed during the traversing of the table,
+ * even if the table was marked as auto rehashable. The caller also must
+ * not call silc_hash_table_rehash while traversing the table.
+ *
***/
void silc_hash_table_find_foreach(SilcHashTable ht, void *key,
SilcHashForeach foreach, void *user_context);
* Traverse all entrys in the hash table and call the `foreach' for
* every entry with the `user_context' context.
*
+ * NOTES
+ *
+ * The hash table will not be rehashed during the traversing of the table,
+ * even if the table was marked as auto rehashable. The caller also must
+ * not call silc_hash_table_rehash while traversing the table.
+ *
***/
void silc_hash_table_foreach(SilcHashTable ht, SilcHashForeach foreach,
void *user_context);
*
* SYNOPSIS
*
- * void silc_hash_table_rehash(SilcHashTable ht, uint32 new_size);
+ * void silc_hash_table_rehash(SilcHashTable ht, SilcUInt32 new_size);
*
* DESCRIPTION
*
* very slow.
*
***/
-void silc_hash_table_rehash(SilcHashTable ht, uint32 new_size);
+void silc_hash_table_rehash(SilcHashTable ht, SilcUInt32 new_size);
/****f* silcutil/SilcHashTableAPI/silc_hash_table_list
*
* DESCRIPTION
*
* Prepares the `htl' SilcHashTableList sent as argument to be used in the
- * hash table traversing with the silc_hash_table_get.
+ * hash table traversing with the silc_hash_table_get. After the hash
+ * table traversing is completed the silc_hash_table_list_reset must be
+ * called.
+ *
+ * NOTES
+ *
+ * The hash table will not be rehashed during the traversing of the list,
+ * even if the table was marked as auto rehashable. The caller also must
+ * not call silc_hash_table_rehash while traversing the list.
*
***/
void silc_hash_table_list(SilcHashTable ht, SilcHashTableList *htl);
+/****f* silcutil/SilcHashTableAPI/silc_hash_table_list_reset
+ *
+ * SYNOPSIS
+ *
+ * void silc_hash_table_list_reset(SilcHashTableList *htl);
+ *
+ * DESCRIPTION
+ *
+ * Resets the `htl' SilcHashTableList. This must be called after the
+ * hash table traversing is completed.
+ *
+ ***/
+void silc_hash_table_list_reset(SilcHashTableList *htl);
+
/****f* silcutil/SilcHashTableAPI/silc_hash_table_get
*
* SYNOPSIS
* DESCRIPTION
*
* Same as silc_hash_table_add_ext but if the `key' already exists in the
- * hash table the old key and the old context will be replace with the
+ * hash table the old key and the old context will be replaced with the
* `key' and the `context. The destructor function will be called for the
* replaced key and context.
*
* SilcHashFunction hash,
* void *hash_user_context,
* SilcHashCompare compare,
- * void *compare_user_context);
+ * void *compare_user_context,
+ * SilcHashDestructor destructor,
+ * void *destructor_user_context);
*
* DESCRIPTION
*
* function. If not provided the hash table's default is used.
* The `compare' and `compare_user_context' are application specified
* comparing function. If not provided the hash table's default is used.
+ * The `destructor' and `destructor_user_context' are application
+ * specific destructor function.
*
***/
bool silc_hash_table_del_ext(SilcHashTable ht, void *key,
SilcHashFunction hash,
void *hash_user_context,
SilcHashCompare compare,
- void *compare_user_context);
+ void *compare_user_context,
+ SilcHashDestructor destructor,
+ void *destructor_user_context);
/****f* silcutil/SilcHashTableAPI/silc_hash_table_del_by_context_ext
*
* SilcHashFunction hash,
* void *hash_user_context,
* SilcHashCompare compare,
- * void *compare_user_context);
+ * void *compare_user_context,
+ * SilcHashDestructor destructor,
+ * void *destructor_user_context);
*
* DESCRIPTION
*
* function. If not provided the hash table's default is used.
* The `compare' and `compare_user_context' are application specified
* comparing function. If not provided the hash table's default is used.
+ * The `destructor' and `destructor_user_context' are application
+ * specific destructor function.
*
***/
bool silc_hash_table_del_by_context_ext(SilcHashTable ht, void *key,
SilcHashFunction hash,
void *hash_user_context,
SilcHashCompare compare,
- void *compare_user_context);
+ void *compare_user_context,
+ SilcHashDestructor destructor,
+ void *destructor_user_context);
/****f* silcutil/SilcHashTableAPI/silc_hash_table_find_ext
*
* The `compare' and `compare_user_context' are application specified
* comparing function. If not provided the hash table's default is used.
*
+ * NOTES
+ *
+ * The hash table will not be rehashed during the traversing of the table,
+ * even if the table was marked as auto rehashable. The caller also must
+ * not call silc_hash_table_rehash while traversing the table.
+ *
***/
void silc_hash_table_find_foreach_ext(SilcHashTable ht, void *key,
SilcHashFunction hash,
*
* SYNOPSIS
*
- * void silc_hash_table_rehash_ext(SilcHashTable ht, uint32 new_size,
+ * void silc_hash_table_rehash_ext(SilcHashTable ht, SilcUInt32 new_size,
* SilcHashFunction hash,
* void *hash_user_context);
*
* function. If not provided the hash table's default is used.
*
***/
-void silc_hash_table_rehash_ext(SilcHashTable ht, uint32 new_size,
+void silc_hash_table_rehash_ext(SilcHashTable ht, SilcUInt32 new_size,
SilcHashFunction hash,
void *hash_user_context);