]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/doc/hashtable.txt
Released as 6.5.16.
[libucw.git] / ucw / doc / hashtable.txt
index 24511f968107bd02fe13d1911c8c2d2c8ebd6964..630b1aa5b0c3631131f031d279189e76ea9f997b 100644 (file)
@@ -52,7 +52,7 @@ You can define any of these macros and provide corresponding functions
 to customize the behaviour. The macros are:
 
 [[give_hashfn]]
-- `HASH_GIVE_HASHFN` -- the table will use `uns
+- `HASH_GIVE_HASHFN` -- the table will use `uint
   HASH_PREFIX(hash)(key)` to calculate hash of `key`.
   There is a sensible default for integers and strings.
   In the case of <<key_complex,`HASH_KEY_COMPLEX`>>, it is mandatory
@@ -78,11 +78,17 @@ to customize the behaviour. The macros are:
   *)` is used to initialize the rest of node. Useful if you use
   <<fun_HASH_PREFIX_OPEN_PAREN_lookup_CLOSE_PAREN_,`HASH_PREFIX(lookup())`>>
 - `HASH_GIVE_ALLOC` -- you need to provide `void
-  \*HASH_PREFIX(alloc)(uns size` and `void HASH_PREFIX(free)(void \*)`
+  \*HASH_PREFIX(alloc)(uint size` and `void HASH_PREFIX(free)(void \*)`
   to allocate and deallocate the nodes. Default uses
-  <<memory:xmalloc()>> and <<memory:xfree()>> or <<mempool:,mempool
-  routines>>, depending on <<use_pool,`HASH_USE_POOL`>> and
-  <<auto_pool,`HASH_AUTO_POOL>> switches.
+  <<basics:xmalloc()>> and <<basics:xfree()>>, <<mempool:mempool
+  routines>> or <<eltpool:eltpool routines>>, depending on
+  <<use_pool,`HASH_USE_POOL`>>, <<auto_pool,`HASH_AUTO_POOL`>>,
+  <<use_eltpool,`HASH_USE_ELTPOOL`>> and <<auto_eltpool,`HASH_AUTO_ELTPOOL`>> switches.
+- <<table_alloc:`HASH_GIVE_TABLE_ALLOC`>> -- you need to provide `void
+  \*HASH_PREFIX(table_alloc)(uint size` and `void HASH_PREFIX(table_free)(void \*)`
+  to allocate and deallocate the table itself. Default uses
+  <<basics:xmalloc()>> and <<basics:xfree()>> or the functions
+  from `HASH_GIVE_ALLOC` depending on <<table_alloc:`HASH_TABLE_ALLOC`>> switch.
 
 [[params]]
 Optional parameters
@@ -106,14 +112,31 @@ You can customize the hash table a little more by these macros:
 [[auto_pool]]
 - `HASH_AUTO_POOL` -- like above, but it creates it's own mempool.
   Define it to the block size of the pool.
+[[use_eltpool]]
+- `HASH_USE_ELTPOOL` -- tells to use <<eltpool:,eltpool allocation>> to
+  allocate the nodes. You should define it to the name of eltpool
+  variable to be used for this purpose.
+[[auto_eltpool]]
+- `HASH_AUTO_ELTPOOL` -- like above, but it creates it's own mempool.
+  Define it to the number of preallocated nodes in each chunk of memory.
 - `HASH_ZERO_FILL` -- initialize new nodes to all zeroes.
+[[table-alloc]]
 - `HASH_TABLE_ALLOC` -- allocate the table the same way as nodes. If
-  not provided, <<mempory:xmalloc()>> is used.
+  not provided, <<basics:xmalloc()>> is used.
+- `HASH_TABLE_GROWING` -- never decrease the size of allocated table of nodes.
 [[table_dynamic]]
 - `HASH_TABLE_DYNAMIC` -- By default, only one global hash table is
   used. With this macro defined, all functions gain new first
   parameter of type `HASH_PREFIX(table) *` to allow them work with
   multiple hash tables.
+- `HASH_TABLE_VARS` -- extra variables to be defined at head
+  of `HASH_PREFIX(table) *` structure. It can be useful in combination
+  with <<table_dynamic:`HASH_TABLE_DYNAMIC`>> to access per-table custom variables
+  from macros or function switches before you include the generator.
+[[lookup_detect_new]]
+- `HASH_LOOKUP_DETECT_NEW` -- the prototype for lookup is changed to `node *lookup(key, int *new_item)`,
+ `new_item` must not be NULL and returns 1 whether lookup just created a new item in the hashtable
+ or 0 otherwise.
 
 [[wants]]
 Functionality switches