by jstanley · 2y ago · 0 comments
Insertion:
%hash = () if keys %hash > 100000;
$hash{$key} = $val;
Retrieval: return $hash{$key};
Desirable properties include bounded memory usage (assuming bounded size of $val), O(1) (amortised) insertion/retrieval, and (most importantly) it only takes a second to write and there's almost 0 chance of writing it wrong.The downside is that the mean utilisation is only 50%.
Has the advantage of lower overhead and simplicity.