GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’… GOLF(2gg) β€” bestie edition ✨

okay so this page lives in the 2gg manual, and it's literally all about one little command that gives your hash table a glow-up. let's get into it 🫢


✨ NAME ✨

resize-hash β€” the (hash) girly πŸ’–


πŸŽ€ PURPOSE πŸŽ€

Resize hash table. that's it, that's the whole job, and she does it flawlessly πŸ’…


🌸 SYNTAX 🌸

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

that's the whole vibe check right there ⭐


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so resize-hash will resize your <hash> table (the one you made with new-hash, obvi) to size <new size>. and <new size>? it's talking about the number of "buckets", aka the possible hash codes derived from the keys stored in there. buckets!! like little containers!! obsessed πŸ“

here's the tea tho. when the number of elements stored grows, the search performance may decline if the hash size stays the same. like, bestie, the table's getting crowded and nobody's happy 😭 and conversely, if the number of elements shrinks, the memory allocated by the hash may be wasted. wasteful!! not the vibe!! so use get-hash to get its current hash-size, its length (that's the number of elements currently stored in it) and the statistics (like average reads) so you can figure out if you actually need to resize it. data-driven decisions only, periodt πŸ‘‘

and now the important warning-ish part: resizing is generally expensive, so don't do it too often, and only when needed. the whole goal is to amortize this expense through future gain of lookup performance. so 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 you're trying to avoid exponential growth. proportional glow-ups stay winning 🌈


🧚 EXAMPLES 🧚

resize-hash h hash-size 100000

look at her go. iconic. no notes πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘

  • Hash

get-hash new-hash purge-hash read-hash resize-hash write-hash

See all documentation 🌸


and that's the whole page bestie!! mwah πŸ’– this was $VERSION from $DATE β€” go slay your hash tables, iykyk βœ¨πŸ‘‘

πŸ“¦ where this page comes from