Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Vectors really don't make linked lists irrelevant - if you want to be able to quickly pop from the middle, no Vec magic will currently help you


view as:

Vectors by themselves don't make linked lists irrelevant, but they remove 90% of the use cases, and most of the remaining ones would be better served by a hashtable, or some sort of fancy tree. Linked lists (especially as C programmers typically implement them) are absolutely awful for performance.

If the order if items in the vector doesn't matter you can swap with the last element and then reduce size by one

Legal | privacy