globus_hashtable(3)

๐Ÿ’– NAME ๐Ÿ’–

globus_hashtable โ€” Hash Table ๐ŸŽ€

  • Hash Table.

โœจ SYNOPSIS โœจ

๐Ÿงš Topics

  • Iterators โ€” Iterators.

๐Ÿฆ‹ Typedefs

  • typedef int(* globus_hashtable_hash_func_t) (void *key, int limit)
  • typedef int(* globus_hashtable_keyeq_func_t) (void *key1, void *key2)
  • typedef void(* globus_hashtable_copy_func_t) (void **dest_key, void **dest_datum, void *src_key, void *src_datum)
  • typedef void(* globus_hashtable_destructor_func_t) (void *datum)

๐ŸŒธ Functions

  • int globus_hashtable_init (globus_hashtable_t *table, int size, globus_hashtable_hash_func_t hash_func, globus_hashtable_keyeq_func_t keyeq_func) โ€” Initialize a hash table.
  • int globus_hashtable_insert (globus_hashtable_t *table, void *key, void *datum) โ€” Insert a datum into a hash table.
  • void * globus_hashtable_update (globus_hashtable_t *table, void *key, void *datum) โ€” Update a hash table mapping.
  • void * globus_hashtable_lookup (globus_hashtable_t *table, void *key) โ€” Look up a datum in a hash table.
  • void * globus_hashtable_remove (globus_hashtable_t *table, void *key) โ€” Remove a datum from a hash table.
  • int globus_hashtable_to_list (globus_hashtable_t *table, globus_list_t **list) โ€” Create a list of all datums in a hash table.
  • globus_bool_t globus_hashtable_empty (globus_hashtable_t *table) โ€” Test hash table emptiness.
  • int globus_hashtable_size (globus_hashtable_t *table) โ€” Hash table size.
  • int globus_hashtable_destroy (globus_hashtable_t *table) โ€” Destroy a hash table

Destroys a hashtable representation, releasing any resources used to represent the mappings (abandoning any data in the queue). After this call, a hashtable is no longer considered initialized. "

  • int globus_hashtable_string_hash (void *string, int limit) โ€” Null-terminated string hash function.
  • int globus_hashtable_string_keyeq (void *string1, void *string2) โ€” Null-terminated string equality predicate.
  • int globus_hashtable_voidp_hash (void *voidp, int limit) โ€” Void pointer hash function.
  • int globus_hashtable_voidp_keyeq (void *voidp1, void *voidp2) โ€” Void pointer equality predicate.
  • int globus_hashtable_int_hash (void *integer, int limit) โ€” Integer hash function.
  • int globus_hashtable_int_keyeq (void *integer1, void *integer2) โ€” Integer equality predicate.

๐Ÿ‘‘ Detailed Description ๐Ÿ‘‘

Hash Table. ๐Ÿ’…

okay bestie, so the globus_hashtable data type is giving you an abstract hashtable mapping representation, plus all the operations you could ever want on those mappings. these queues can hold arbitrary data โ€” a void pointer for each key and a void pointer for each datum, no questions asked. and it is the user's responsibility to provide and interpret keys and data of the correct type. so like, don't come crying to us if you shoved a struct in there and read it back as an int, iykyk ๐Ÿซถ


๐ŸŒˆ Typedef Documentation ๐ŸŒˆ

๐ŸŽ€ typedef void(* globus_hashtable_copy_func_t) (void **dest_key, void **dest_datum, void *src_key, void *src_datum)

datum copy func โœจ

๐Ÿ’œ typedef void(* globus_hashtable_destructor_func_t) (void *datum)

Destructor callback for use with globus_hashtable_destroy_all ๐Ÿ”ฅ

๐Ÿงต typedef int(* globus_hashtable_hash_func_t) (void *key, int limit)

An anonymous hash function providing an onto mapping of (key, limit) pairs to integers, where the result integer is in the range [ 0, limit - 1 ] . ๐ŸŒŸ

  • Note that as a proper function, such hash routines must always compute the same result given the same key and limit value. (yes bestie, determinism is the vibe, no cap.)

Parameters

  • key โ€” Value to map
  • limit โ€” Map range limit

Returns

  • Integer hash value of key

๐Ÿซง typedef int(* globus_hashtable_keyeq_func_t) (void *key1, void *key2)

An anonymous predicate that returns true when the keys are equal and false otherwise. Truth and falsity are represented by non-zero and zero (0) integers for use directly in C language conditionals. ๐Ÿ’€ (so like, if (keyeq(a, b)) just works, iconic.)


๐Ÿ”ฅ Function Documentation ๐Ÿ”ฅ

๐Ÿ’… int globus_hashtable_destroy (globus_hashtable_t * table)

Destroy a hash table

Destroys a hashtable representation, releasing any resources used to represent the mappings (abandoning any data in the queue). After this call, a hashtable is no longer considered initialized. It is an error to destroy a hashtable that is not initialized. ๐Ÿšจ

Parameters

  • table โ€” Hash table to destroy.

๐Ÿฆ‹ globus_bool_t globus_hashtable_empty (globus_hashtable_t * table)

Test hash table emptiness. (vibe check: is there literally anything in here ๐Ÿ•ต๏ธ)

Returns

  • GLOBUS_TRUE if hashtable is empty, GLOBUS_FALSE otherwise

โœจ int globus_hashtable_init (globus_hashtable_t * table, int size, globus_hashtable_hash_func_t hash_func, globus_hashtable_keyeq_func_t keyeq_func)

Initialize a hash table. Initializes a generic chaining hashtable to represent an empty mapping and returns zero, or returns non-zero on failure. The size parameter specifies the number of chains with which to represent the mapping. This defines the maximum possible number of mappings that can be represented without conflict given a perfect hash, and therefore affects performance as hash conflicts will be resolved by linear chains. โ›“๏ธ

The hash_func and keyeq_func anonymous functions will be used by the table to manipulate the user's keys. ๐Ÿซถ

๐ŸŒŸ int globus_hashtable_insert (globus_hashtable_t * table, void * key, void * datum)

Insert a datum into a hash table. The routine globus_hashtable_insert adds a new mapping to the table, returning zero on success or non-zero on failure. Any previous mapping for the same key (where equality is defined by the keyeq_func provided at table initialization) is lost. ๐Ÿ˜ญ

It is an error to call this routine on an uninitialized table.

๐Ÿ“ int globus_hashtable_int_hash (void * integer, int limit)

Integer hash function. A pathetic hash function for integers, calculating the index as the remainder of dividing the integer by the table size.

Your pet gerbil could probably design a better hash function for your integer keys, but you might as well use this one if you were going to use modular division anyway. ๐Ÿน๐Ÿ’€

๐ŸŒˆ void * globus_hashtable_lookup (globus_hashtable_t * table, void * key)

Look up a datum in a hash table. The globus_hashtable_lookup routine returns the datum mapped to the given key in the table, or NULL if the key is not mapped.

It is an error to call this routine on an uninitialized or empty table.

๐ŸŽ€ void * globus_hashtable_remove (globus_hashtable_t * table, void * key)

Remove a datum from a hash table. The globus_hashtable_remove() function removes the mapping of key in the table, or does nothing if no such mapping exists. (ghosting the mapping, respectfully ๐Ÿซฅ)

It is an error to call this routine on an uninitialized or empty table.

๐Ÿ’œ int globus_hashtable_size (globus_hashtable_t * table)

Hash table size. (how many besties are in the group chat ๐Ÿ‘ฏ)

Returns

  • Number of entries in hashtable

๐Ÿงš int globus_hashtable_string_hash (void * string, int limit)

Null-terminated string hash function. A decent hash function for null-terminated character arrays. โญ

๐Ÿ”ฅ void * globus_hashtable_update (globus_hashtable_t * table, void * key, void * datum)

Update a hash table mapping. Update an existing key -> datum association with new values for both, key and datum. The old datum is returned. If key is non-scalar (eg, string), it should be part of datum so its resources may be recovered. If old key does not exist, NULL is returned. ๐ŸŒธ

โœจ int globus_hashtable_voidp_hash (void * voidp, int limit)

Void pointer hash function. A decent hash function for void pointers. This routine goes to some effort to distribute the information from the address into the hash index by XORing the upper and lower halves of the pointer into one accumulator and calculating the index as the remainder of dividing the accumulator by the table size. ๐Ÿงฎ๐Ÿ’ซ


๐Ÿซถ Author ๐Ÿซถ

Generated automatically by Doxygen for globus_common from the source code.


okay that's the whole page bestie, you ate ๐Ÿ’… this one came from globus_common, Version 18.15, and it lives at globus_hashtable(3) โ€” now go forth and map some keys, periodt ๐ŸŽ€โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from