Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Linked lists considered harmful

Name: Anonymous 2009-10-10 20:46

  ↑    slava_pestov 4 points 5 hours ago [-]
  ↓    A perfect illustration of why single linked lists are simply the wrong data structure in
        99% of cases. Just use arrays and you won't have to choose between tail recursion, and
        front-to-back iteration order.
        permalink report reply

Name: Anonymous 2009-10-10 20:54

>>4
1) not nearly as easy to extend
If you need an extensible data structure, use a vector backed by an array (or a hashtable of arrays). If you can't afford to do that in your program, you shouldn't be writing an algorhythm that needs an extensible data structure.

2) usage can be less comfortable (pushing/poping to/from and others)
Comfort is never a sufficient excuse for the evils of linked lists. Write a stack/queue that stores its contents in an extensible vector like any sane person would do, and then you can iterate over the elements properly.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List