c# - Wants next Stack<T> from the list of Actions -
i making undoredo functionlity application. on function doaction have list of action taken in stack<undoredoaction> want last action taken automatically first in list take out first in list have used actionlist.peek(); situation arise next time wanted take second 1 list. not sure how
private void doaction(stack<undoredoaction> actionlist, stack<undoredoaction> storelist, action<undoredoaction> action) { if (actionlist.count > 0) { undoredoaction uraction = actionlist.peek(); action(uraction); storelist.push(uraction); } }
you need use stack<t>.pop instead of peek. pop removes last added item in stack , returns while peek returns last added item without removing stack.
Comments
Post a Comment