int SetOfStacks::popAt(int i) { std::stack<int>& stackToPop = stacks.at(i); int toReturn = stackToPop.top(); stackToPop.pop(); // Shift stacks after i left shiftStacks(i); return toReturn; }
bool del(int* chptr) { shiftStacks(); if(oldest.size()==0) return 0; *chptr = oldest.top(); oldest.pop(); return 1; }
void add(int ch) { if(popped) { popped=0; shiftStacks(); } Stacks[cur].push(ch); }
bool del(int* chptr) { if(Stacks[cur].size()==0) return 0; if(!popped) { popped = 1; shiftStacks(); } *chptr=Stacks[cur].top(); Stacks[cur].pop(); return 1; }
int deQueue(){ shiftStacks(); return oldStack.pop(); }