LinkedList and a Limited Undo Stack
Submitted on Jun 07, 2008, 10:35 a.m.
I needed an undo stack today - but wanted it to behave like a queue when it was full, dropping the oldest items in the collection to make room for new ones. Found two posts - Undo Functionality with a Limited Stack , and also a reference to an identically named collection called LimitedStack here.
Was initially thinking of simply writing a wrapper over an array of objects, shifting items along as new ones were added, but using a linked list is a clever solution, as it provides the queue like behavior needed without out any extra code via RemoveFirst() and RemoveLast().