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 33,209 of 33,346   
   kira2kk@googlemail.com to Ike Naar   
   Re: found the missing items in a contain   
   17 Sep 13 08:03:33   
   
   { reformatted manually to ~70 chars per line. --mod }   
      
   On Sunday, September 15, 2013 9:10:05 PM UTC+8, Ike Naar wrote:   
   > If the ID of an element is supposed to be the same as the position of   
   >   
   > the element in the container, then what is the use of storing the ID   
   >   
   > together with the element? You can just as easily keep track of the ID   
   >   
   > while traversing the container.   
      
   I am sorry I provide inappropriate example. The position and the ID   
    of the element are just happened to be same. But it does not mean   
    they are always the same. And the Id of the remove is marked as -1.   
   e.g. the first item will be remove in seqence {1,2,3,4,5} -> assign   
    new ID when certain condition triggers {-1, 1, 2, 4, 5} -> remove   
    all items with ID is -1 -> {1, 2, 4, 5}   
      
   since the ID 3 is missed, it will be insert at the proper position   
    -> {1,2,3,4,5}   
      
   That is the whole logic. At step 2, I traverse the container and assign   
    the new ID. At the last step, I brutal search the missing item, and add   
    it back.   
      
   --   
         [ 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