Why do some collection data structures not maintain the order of insertion? What is the special thing achieved compared to maintaining order of insertion?
Do we gain something if we don’t maintain the order?
Why do some collection data structures not maintain the order of insertion? What is
Share
Performance. If you want the original insertion order there are the
LinkedXXXclasses, which maintain an additional linked list in insertion order. Most of the time you don’t care, so you use aHashXXX, or you want a natural order, so you useTreeXXX.In either of those cases why should you pay the extra cost of the linked list?