From: jklowden@speakeasy.net   
      
   On Sat, 9 Mar 2013 08:52:21 CST   
   Öö Tiib wrote:   
      
   > On Friday, 8 March 2013 17:20:30 UTC+2, alexo wrote:   
   > > I'd like to insert a node in a linked list in a sorted manner. from   
   > > smaller to bigger   
   >   
   > Can you tell us the reason why you use linked list for sorted   
   > container? I would likely review such usage as a design defect.   
   ....   
   > For inserting into top and bottom use deque or ring buffer. For   
   > sorted container use set or map.   
      
   Öö, I think the OP's purpose is to learn about linked lists. Agreed   
   using set/map from the standard library makes writing this kind of code   
   unnecessary in C++, but it's hard to appreciate how wonderful they are   
   never having written one.   
      
   A linked list is, from a theoretical standpoint, a perfectly reasonable   
   data structure for ordered data. Sure, a binary tree is faster to   
   seek over. But a list is perfectly adequate for "small N, and N is   
   usually small" as Rob Pike put it, and has nothing like the complexity   
   of a tree.   
      
   --jkl   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|