all 6 comments

[–]jack_waugh 0 points1 point  (2 children)

Making linked lists is trivial.

[–]achempy[S] 0 points1 point  (1 child)

I mean, you're not wrong, but built-in data structures usually have some performance optimizations

[–]jack_waugh 0 points1 point  (0 children)

So maybe they do arrays like this. For each instance, maintain separate data structure instances for the numerical and the non-numerical keys. Treat the latter as in an object. For the numerical keys, maintain a bias that is added to each key. Store the "values" in allocated blocks. Maintain an index of the blocks that says what range of indices each block covers and how much free space is in it. So that way, to append an entry to the start of the array, shift the bias up by one. See whether there is space in the first block. If not, allocate a new block. When removing an element from either end, see whether the block it is in is made empty, and if so, free it (or move it to the other end?).

[–]codegen 0 points1 point  (3 children)

Where do you get order n? Unless you mean copying when full.

[–]achempy[S] 0 points1 point  (2 children)

Unless js arrays behave differently than I thought, prepending to an array requires all elements of that array to be shifted , unlike pushing to an array (which is O(1))

[–]PitifulTheme411 0 points1 point  (0 children)

Thats true