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,909 of 33,346   
   Andy Champ to Francis Glassborow   
   Re: insert [sorted] a node in a linked l   
   10 Mar 13 16:21:30   
   
   From: no.way@nospam.invalid   
      
   On 10/03/2013 07:47, Francis Glassborow wrote:   
      
   > The problem is that it is expensive in storage when the elements are small.   
   >   
   That's not the only problem. It's slow for random access too.   
      
      
   > As a matter of interest, what container would you suggest be used for   
   > substantial amounts of text (e.g. a 500 page book)?   
   >   
      
   As a first guess - a std::list, where the strings   
   _include_ such things as paragraph, line and chapter markers, and are   
   split in half when they grow above some threshold size, and joined when   
   the combined size of 2 adjacent ones fall below some other threshold   
   size - the latter threshold being maybe a third of the former.   
      
   Then abstract this away from the code doing the editing, because it's a   
   guess and is probably wrong :)   
      
   edit-move then becomes - locate source text. Split containing string(s)   
   at front and end boundaries. Split target string at insertion point.   
   Move source string(s) from source location in list to insertion point.   
   Normalise string lengths to be between thresholds.   
      
   This is so much easier than it was when I looked at this as a student   
   exercise in Pascal :)   
      
   Andy   
      
      
   --   
         [ 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