updates.
[silc.git] / lib / silcutil / silchashtable.h
index fd73e7d0b5c98a0f784c66008debaa68a2465850..f05e99e0ef0aab4af8b2d4337e76e802cbe3de47 100644 (file)
@@ -1,24 +1,24 @@
-/****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 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.
+
+*/
+
+/****h* silcutil/SilcHashTableAPI
  *
  * DESCRIPTION
  *
@@ -80,6 +80,7 @@ typedef struct SilcHashTableStruct *SilcHashTable;
  *    silc_hash_table_list(hash_table, &htl);
  *    while (silc_hash_table_get(&htl, (void *)&key, (void *)&context))
  *      ...
+ *    silc_hash_table_list_reset(&htl);
  *
  * SOURCE
  */
@@ -90,6 +91,7 @@ struct SilcHashTableListStruct {
   SilcHashTable ht;
   void *entry;
   uint32 index;
+  bool auto_rehash;
 };
 /***/
 
@@ -383,11 +385,33 @@ void silc_hash_table_rehash(SilcHashTable ht, uint32 new_size);
  * 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
@@ -462,7 +486,9 @@ void silc_hash_table_replace_ext(SilcHashTable ht, void *key, void *context,
  *                                 SilcHashFunction hash, 
  *                                 void *hash_user_context,
  *                                 SilcHashCompare compare, 
- *                                 void *compare_user_context);
+ *                                 void *compare_user_context,
+ *                                 SilcHashDestructor destructor,
+ *                                 void *destructor_user_context);
  *
  * DESCRIPTION
  *
@@ -474,13 +500,17 @@ void silc_hash_table_replace_ext(SilcHashTable ht, void *key, void *context,
  *    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
  *
@@ -491,7 +521,9 @@ 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);
  *
  * DESCRIPTION
  *
@@ -504,6 +536,8 @@ bool silc_hash_table_del_ext(SilcHashTable ht, void *key,
  *    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, 
@@ -511,7 +545,9 @@ 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
  *