Vely logo install | documentation | examples | changelog
16.10.0 released May 10, 2023

Purpose: Create hash table.

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

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 elements with the same hash code are stored in a linked list within the same bucket. Greater table size usually means less elements 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.
Allocated internals
<hash> is allocated memory along with additional internal memory, which can be released if purge-hash is used with <hash> from a previously executed new-hash.
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) 2017-2023 Dasoftver LLC