4 ms·
Until then, why do not we all just stay away from the linked-list for the time being? After all C++ is all about performance - and linked-list is not! No, than
by mrmaddog 15y ago
Until then, why do not we all just stay away from the linked-list for the time being? After all C++ is all about performance - and linked-list is not!
No, thank you. Instead, why don't we try and understand the benefits and pitfalls of various data structures? Although linked lists may not be a great generic data structure, they can be incredibly useful for certain types of actions. Enumerating their strengths is a much more useful exercise than asserting sweeping generalizations.
As for your example: any stack or queue data structure is more efficiently implemented with a linked list than an array/vector. (Or any data structure that just needs to do operations on the head/tail of a data structure.)
- Adrock 15y agoIn Java, I've never seen a linked list implementation outperform the stock implementation of an array-backed deque for stacks or queues. http://docs.oracle.com/javase/6/docs/api/java/util/ArrayDeque.html http://docs.oracle.com/javase/6/docs/api/java/util/ArrayDequ... I highly recommend that every Java developer read the source for this class (and the rest of the java.util Collections).
- yread 15y agoor operation like "move elements in the range 1000..5000 to the beginning"