Vely logo Empower C
install  tutorials  examples
documentation  license  about

12.1.0 released on Sep 19, 2022

resize-hash



PURPOSE:


Resize hash table.

SYNTAX:


resize-hash <hash> size <new size>


DESCRIPTION:


resize-hash will resize hash table <hash> (created by new-hash) to size <newsize>, which refers to the number of "buckets", or possible hash codes derived from keys stored.

When a number of keys stored grows, the search performance may decline if hash table size remains the same. Consequently, if the number of keys shrinks, the memory allocated by the hash table may be wasted. Use get-hash to obtain its current size, its length (the number of elements currently stored in it) and the statistics (such as average reads) to determine if you need to resize it.

Resizing is generally expensive, so it should not be done too often. The goal is to amortize this expense through future gain of lookup performance. For that reason it may be better to resize proportionally (i.e. by a percentage), unless you have a specific application reason to do otherwise, or to avoid exponential growth.

EXAMPLES:


resize-hash h size 100000


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.