Resize array

Purpose: Resize array's hash table.

 resize-array <array> hash-size <new size>

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

When a number of elements stored grows, the search performance may decline if array size remains the same. Consequently, if the number of elements shrinks, the memory allocated by the array may be wasted. Use get-array to obtain its current hash-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, and only when needed. 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-array h hash-size 100000

See also
Array
get-array  
new-array  
purge-array  
read-array  
resize-array  
write-array  
See all
documentation


Copyright (c) 2019-2024 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.