@@ -39,6 +39,7 @@ template <class T, class D> class Problem {
3939 // Running the stack
4040 void run ();
4141 void run (int limit);
42+ void readPush (int iter = 1 );
4243 void push (Data<T, D> elt);
4344 Data<T, D> pop ();
4445 Data<T, D> top (int k);
@@ -202,7 +203,7 @@ std::vector<std::string> Problem<T, D>::readHeader() {
202203}
203204
204205/* ==============================================================================
205- Stack Functions: run, push, pop, top
206+ Stack Functions: run, push, pop, top, readPush
206207==============================================================================*/
207208template <class T , class D > void Problem<T, D>::run() {
208209 initStackIntern ();
@@ -249,6 +250,19 @@ template <class T, class D> void Problem<T, D>::run(int limit) {
249250 }
250251}
251252
253+ template <class T , class D > void Problem<T, D>::readPush(int iter) {
254+ for (int i = 0 ; i < iter; i++) {
255+ std::streampos position = mInput .tellg ();
256+ (*mStack ).setPosition (position);
257+ std::vector<std::string> line = readLine ();
258+ D data = readInput (line);
259+ mIndex ++;
260+ Data<T, D> elt (mIndex , data);
261+ pushAction (elt);
262+ push (elt);
263+ }
264+ }
265+
252266template <class T , class D > void Problem<T, D>::push(Data<T, D> elt) {
253267 mStack ->push (elt);
254268}
0 commit comments