home bbs files messages ]

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

   comp.programming      Programming issues that transcend langua      57,431 messages   

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

   Message 55,660 of 57,431   
   Kristjan Robam to All   
   Re: Undo / Redo design pattern.   
   04 Apr 22 04:04:46   
   
   From: ya3891921@gmail.com   
      
   Something for You.   
      
   Can You help me out with 2100 euros ?   
      
   I want to buy a new Iphone.   
      
      
      
   Kristjan Robam   
      
   Malcolm McLean kirjutas Pühapäev, 3. aprill 2022 kl 14:16:14 UTC+3:   
   > To implement a simple undo redo, you need two stacks, and a copyable   
   representation of the program state. You then push to the undo stack, with   
   straight forwards extensions for redo.    
   >    
   > However this is memory greedy. So it is better to use the following pattern,   
   on stack push, take the difference between stack top and the object being   
   pushed. Then delete stack top, and replace with the difference between the   
   pushed object and stack    
   top, then push. To pop the stack, apply the difference to stack top, and set   
   it as new stack top.    
   >    
   > This could be made generic, but it involves a user-supplied delta codec   
   which could be hard to write. Another way of doing it is to feed everything   
   through a tostring / fromstring representation.    
   >    
   > The problem is now reduced to writing the delta codec for two strings. The   
   proper way to do this is to use a string alignment algorithm, but that is   
   likely to be overkill. The majority of changes will be either one character or   
   one indel. If we've got    
   more than few changes, we can simply resort to storing the entire string.   
      
   --- 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