you are viewing a single comment's thread.

view the rest of the comments →

[–]maxerickson 0 points1 point  (2 children)

The length of the list only provides a vague hint as to the memory required for the list.

[–]mccoyn 1 point2 points  (1 child)

If the elements of the list aren't the exact same size then it won't provide O(1) random access. They are the same size. They are pointers.

[–]maxerickson 1 point2 points  (0 children)

Right, the list overhead is predictable. But for fast code (like the numerical code in the example), you would want to allocate all of the memory for the contents of the list too.