Diff for /parser3/src/include/pa_stack.h between versions 1.4 and 1.17.2.6.2.4

version 1.4, 2001/03/08 15:15:45 version 1.17.2.6.2.4, 2003/04/02 08:11:31
Line 1 Line 1
 /*  /** @file
   $Id$          Parser: stack class decl.
   
           Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
           Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
 */  */
   
 #ifndef PA_STACK_H  #ifndef PA_STACK_H
 #define PA_STACK_H  #define PA_STACK_H
   
   static const char* IDENT_STACK_H="$Date$";
   
   #include "pa_config_includes.h"
 #include "pa_array.h"  #include "pa_array.h"
   
 class Stack : public Array {  /// simple stack based on Array
   template<typename T> class Stack: public Array<T> {
 public:  public:
   
         Stack(Pool& apool) : Array(apool), ftop(0) {          Stack(): ftop(0) {}
         }  
   
         void push(Item *item) {          void push(T item) {
                 if(ftop<size()) // cell is already allocated?                  if(ftop<count()) // cell is already allocated?
                         put(ftop, item); // use it                          /*unchecked_*/put(ftop, item); // use it
                 else                  else
                         *this+=item; // append it                          *this+=item; // append it
                 ftop++;                  ftop++;
         }          }
         Item *pop() {  
           T pop() {
                 return get(--ftop);                  return get(--ftop);
         }          }
   
         int top_index() { return ftop-1; }          size_t top_index() { return ftop-1; }
         Item *top_value() { return get(top_index()); }          void top_index(size_t top_index) { ftop=top_index+1; }
           T top_value() { return get(top_index()); }
   
           /// call this prior to collecting garbage [in unused part of stack there may be pointers(unused)]
           void wipe_unused() {
                   if(!is_full())
                           memset(&felements[fused], 0, (fallocated-fused)*sizeof(T));
           }
   
 private:  private:
   
         // deepest used index          // deepest used index+1
         int ftop;          size_t ftop;
   
 };  };
   
 #endif  #endif

Removed from v.1.4  
changed lines
  Added in v.1.17.2.6.2.4


E-mail: