Vely logo Empower C
install  tutorials  examples
documentation  license  about

12.1.0 released on Sep 19, 2022

new-hash



PURPOSE:


Create hash table.

SYNTAX:


new-hash [ define ] <hash> size <size>


DESCRIPTION:


new-hash initializes hash table named <hash>, which is a pointer to type "vely_hash" and can be created with optional "define".  <size> is the number of "buckets" in the hash table. All items with the same hash code are stored in a linked list within the same bucket. Greater table size usually means less items per bucket and better performance. However, memory usage grows with a bigger hash table, so its size should be balanced based on the program needs.

Vely uses high-performing FNV1_a hash algorithm. Each element in a bucket list is lightweight, containing pointers to a key, value and next element in the linked list.

Note that a hash table is accessible to the current process only. <size> must be at least 10; if less, it will be set to 10.

EXAMPLES:


Create a new hash with 500 buckets:
new-hash define h size 500

See read-hash for more examples.

SEE ALSO:


Hash table ( get-hash   new-hash   purge-hash   read-hash   resize-hash   write-hash  )  SEE ALL (documentation)



Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Icons copyright PaweĊ‚ Kuna licensed under MIT. This web page is licensed under CC-BY-SA-4.0.