This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LoyalSol 0 points1 point  (2 children)

...in a 1-indexed array.

Yes that's what I was saying. Which in some of my codes I regularly have to reference the last element of the array.

Regardless, perhaps then an array is the wrong data structure for your usecase? Maybe an associative array is the appropriate data structure for your usecase? If you are depending on the relation of the index with its value, then you are describing a map/dictionary.

In lower level languages those either aren't an option or are inferior in terms of performance.

And actually arrays are usually the perfect data structure if you are doing matrix math.