Vely logo install
examples
documentation

Vely 15.2.0 released on Jan 18, 2023
Articles updated Jan 17, 2023

new-hash


Issues with this documentation page? Report here.

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. Vely elephant logo (c) 2022 DaSoftver LLC. This web page is licensed under CC-BY-SA-4.0.