Diff for /parser3/src/include/pa_array.h between versions 1.89 and 1.90

version 1.89, 2024/09/07 16:30:26 version 1.90, 2024/09/10 19:09:56
Line 13 Line 13
 // includes  // includes
   
 #include "pa_memory.h"  #include "pa_memory.h"
   #include "pa_types.h"
 #include "pa_exception.h"  #include "pa_exception.h"
   
 // forwards  // forwards
   
 template<typename T> class Array_iterator;  template<typename T> class Array_iterator;
   template<typename T> class Array_reverse_iterator;
   
 // defines  // defines
   
Line 27  template<typename T> class Array_iterato Line 29  template<typename T> class Array_iterato
 template<typename T> class Array: public PA_Object {  template<typename T> class Array: public PA_Object {
   
         friend class Array_iterator<T>;          friend class Array_iterator<T>;
           friend class Array_reverse_iterator<T>;
   
 protected:  protected:
   
Line 41  protected: Line 44  protected:
   
 public:  public:
         typedef Array_iterator<T> Iterator;          typedef Array_iterator<T> Iterator;
           typedef Array_reverse_iterator<T> ReverseIterator;
   
         struct Action_options {          struct Action_options {
                 size_t offset;                  size_t offset;
Line 172  public: Line 176  public:
         inline T operator [](size_t index) const { return get(index); }          inline T operator [](size_t index) const { return get(index); }
   
         inline void clear() {          inline void clear() {
                   if(fused)
                           memset(felements, 0, fused * sizeof(T));
                 fused=0;                  fused=0;
         }          }
   
Line 268  public: Line 274  public:
   
         Array_iterator(const Array<T>& aarray): farray(aarray) {          Array_iterator(const Array<T>& aarray): farray(aarray) {
                 fcurrent=farray.felements;                  fcurrent=farray.felements;
                 flast=farray.felements+farray.count();                  flast=farray.felements + farray.count();
         }          }
   
         /// there are still elements          /// there are still elements
         operator bool () {          inline operator bool () {
                 return fcurrent<flast;                  return fcurrent < flast;
         }          }
   
         /// returns the current element and advances the iterator          /// returns the current element and advances the iterator
         T next() {          inline T next() {
                 return *(fcurrent++);                  return *(fcurrent++);
         }          }
   
         /// returns the current element          /// returns the current element
         T value() {          inline T value() {
                 return *(fcurrent);                  return *(fcurrent);
         }          }
   
         // returns the current index of the iterator          // returns the current index of the iterator
         size_t index() {          inline size_t index() {
                 return fcurrent - farray.felements;                  return fcurrent - farray.felements;
         }          }
   
           inline char *key(){
                   char local_buf[MAX_NUMBER];
                   size_t length=snprintf(local_buf, MAX_NUMBER, "%zu", index());
                   return pa_strdup(local_buf, length);
           }
   
   };
   
   template<typename T> class Array_reverse_iterator {
   
           const Array<T>& farray;
           T *fcurrent;
   
   public:
   
           Array_reverse_iterator(const Array<T>& aarray): farray(aarray) {
                   fcurrent=farray.felements+farray.count();
           }
   
           /// there are still elements
           inline operator bool () {
                   return fcurrent > farray.felements;
           }
   
           /// returns the current element and advances the iterator
           inline T prev() {
                   return *(--fcurrent);
           }
   
           // returns the current index of the iterator
           inline size_t index() {
                   return fcurrent - farray.felements;
           }
   
           inline char *key(){
                   char local_buf[MAX_NUMBER];
                   size_t length=snprintf(local_buf, MAX_NUMBER, "%zu", index());
                   return pa_strdup(local_buf, length);
           }
   
 };  };
 #endif  #endif

Removed from v.1.89  
changed lines
  Added in v.1.90


E-mail: