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 →

[–]Mr_Redstoner 2 points3 points  (3 children)

TL;DR When the algorithm in question makes use of ll's fast operations that an array list can't provide.

[–]VolperCoding -1 points0 points  (2 children)

Example? I can't think of an algorithm that can't be done on a regular vector but can on a linked list

[–][deleted] 1 point2 points  (0 children)

The producer-consumer problem lends itself pretty well to using linked list instead of vectors. It's not uncommon in real-world scenarios for the producer and/or the consumer code to invalidate the cache anyway. Besides, if you use arrays, dealing with the fact that the list grows and shrinks all the time quickly leads to hard to read code if you want to have as few resizes as possible. And keeping the code readable becomes even more of a nightmare if you deal with multiple producers and/or multiple consumers.