I read about undo / redo methods, I understand how this should be implemented (I found it intuitively).
However, I’m thinking of a collection that should be used as a story,
Many people use the stack, but C # stack is implemented as an array, and this is the problem: If I use a "limited" history (for example, for 2000 commands) when the limit is reached, I have no way to remove elements from the end of the stack, and if I find The way to do this, I have to move all the elements of the array (and this is for every moment the command is executed).
LinkedList looks good, but it spends a lot of memory.
My last option is a custom implementation of a linked list, SingleLinkedList. A node of this list consists of the Value property and the NextNode pointer property, so I use double memory for each element (but nothing more, except when I use things smaller than "sizeof (void *)").
I also keep a pointer to the first item and a pointer to the last item in the collection.
I can easily add commands to the story and move them to the replay in this way, however I cannot create a “limited” story because RemoveLast is not allowed (I need to go through the entire collection to remove the last item).
So my question is: Should I use LinkedList or my own SingleLinkedList?
Update 1:
, , , , , " " ", / (obviusly " ++ ", ).
, singlelinkedlist , , Photoshop, "".
, , , 8 .
LinkedList.
- , , 60000 ( , ), (4 * 60000) singlelinkedlist.
, , LinkedList, , , , ?
2:
@Akash Kava , , , LinkedList . Stack , , , ( , , ).
( , ) , ( - O (1)) . , , , singlelinkedlist ( ), node node.
, LinkedList, Previous.
2 "Stack" ( ), 3 , , ( , singlelinkedlist 2 , 3- ).
, "" -.
, 60000 1 , 5 , .
, /, LinkedList, SingleLinkedList.