Bin Sub-Package

The Bin sub-package provides an API that builds an association between a binary key and a value. Using the Bin sub-package involves three steps: creation, insertion, and retrieval. The data store is created by calling prg_bin_hash_table_create(). This determines the number of cells in the hash table as well as the maximum number of bytes that will be used by the hashing function. A larger number of bytes will help minimize the number of collisions at the cost of increasing the hash function computation time. A larger number of cells will decrease the probability of a collision at the cost of increased memory usage when the hash table is sparsely populated.

After the data store has been created, (key,value) pairs can be inserted using prg_bin_hash_table_item_insert() and removed with prg_bin_hash_table_item_remove(). The value associated with a key can be retrieved by calling prg_bin_hash_table_item_get(). A list of all (key,value) pairs in a hash table can be obtained with prg_bin_hash_table_item_list_get(). You can determine the number of items in a hash table with prg_bin_hash_table_num_items_get().

When a hash table is no longer needed, destroy it by using prg_bin_hash_table_destroy().

The Bin sub-package also contains two functions for computing the hash value for a block of binary data: prg_bin_hash_bytes_array() and prg_bin_hash_int_array().