home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,902 of 33,346   
   James K. Lowden to ootiib@hot.ee   
   Re: insert [sorted] a node in a linked l   
   09 Mar 13 23:47:49   
   
   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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca