Diff for /parser3/src/include/pa_stack.h between versions 1.1 and 1.7

version 1.1, 2001/02/21 17:36:30 version 1.7, 2001/03/19 15:29:38
Line 1 Line 1
 /*  /** @file
   $Id$          Parser
           Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
           Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
   
           $Id$
 */  */
   
 #ifndef PA_STACK_H  #ifndef PA_STACK_H
Line 7 Line 11
   
 #include "pa_array.h"  #include "pa_array.h"
   
   /// simple stack based on Array
 class Stack : public Array {  class Stack : public Array {
 public:  public:
   
         Stack(Pool& apool) : Array(apool), top(0) {          Stack(Pool& apool) : Array(apool), ftop(0) {
         }          }
   
         void push(Item *item) {          void push(Item *item) {
                 if(top<size()) // cell is already allocated?                  if(ftop<size()) // cell is already allocated?
                         put(top, item); // use it                          put(ftop, item); // use it
                 else                  else
                         *this+=item; // append it                          *this+=item; // append it
                 top++;                  ftop++;
         }          }
         Item *pop() {          Item *pop() {
                 return get(--top);                  return get(--ftop);
         }          }
   
         Item *operator [] (int top_offset) {          int top_index() { return ftop-1; }
                 return get(top-top_offset-1);          Item *top_value() { return get(top_index()); }
         }  
   
 private:  private:
   
         // deepest used index          // deepest used index
         int top;          int ftop;
   
 };  };
   

Removed from v.1.1  
changed lines
  Added in v.1.7


E-mail: