Integer-indexed arrays:
This is an in-order binary tree, where the tree nodes directly contain the items.
The bigger an array gets, the slower lookups will get in it but they'll be fairly consistent for a given size. Iterating the tree is faster than individually looking up indexes in turn.
The array-bits
is the number of "hash" bits used to traverse the tree with 16-bit integer index keys. The array-length
is the highest index inserted so far plus one; when it exceeds 2^array-bits
, add a layer to the tree and move the old tree into the left hand. Start traversals with the most significant bit within the hash size for proper ordering.
Note that the object exposes a string-indexed property tree too, here elided into a single property descriptor for length
, which mirrors the internal 16-bit length with a JS number
.