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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -