Updated 2014-07-16 00:08:12 by AMG
array statistics arrayName

Returns statistics about the distribution of data within the hashtable that represents the array called arrayName. This information includes the number of entries in the table, the number of buckets, and the utilization of the buckets. It's only intended to be (expert) human-readable.

AMG: For ideal performance, each bucket would have zero or one entries in it. This yields constant-time lookups. Performance degrades to linear (like with [lsearch] without -sorted) as more entries are placed in each bucket.

To counteract this effect, Tcl arrays (and dicts) have a maximum loading factor of three elements (average) per bucket. When this load factor is exceeded, the array is reallocated to have four times as many buckets as before.

Computation of hash keys for array lookup is linear with respect to key length (in bytes, not characters). However, keys tend to have similar lengths, so it's a reasonable simplification to treat hash key computation as taking constant time.

See also edit