Diff for /parser3/src/include/pa_array.h between versions 1.94 and 1.99

version 1.94, 2024/09/16 23:22:52 version 1.99, 2024/10/26 18:53:37
Line 53  public: Line 53  public:
                 bool defined;                  bool defined;
                                   
                 Action_options(                  Action_options(
                         size_t aoffset=0,                           size_t aoffset=0,
                         size_t alimit=ARRAY_OPTION_LIMIT_ALL,                           size_t alimit=ARRAY_OPTION_LIMIT_ALL,
                         bool areverse=false):                           bool areverse=false):
                         offset(aoffset), limit(alimit), reverse(areverse),                           offset(aoffset), limit(alimit), reverse(areverse), 
                         defined(false) {}                          defined(false) {}
   
Line 71  public: Line 71  public:
                         if(!m)                          if(!m)
                                 return false;                                  return false;
                         // fix limit                          // fix limit
                         if(limit==ARRAY_OPTION_LIMIT_ALL || limit>m)                          if(limit>m)
                                 limit=m;                                  limit=m;
   
                         return true;                          return true;
Line 108  public: Line 108  public:
         }          }
   
         /// append other Array portion to this one. starting from offset          /// append other Array portion to this one. starting from offset
         Array& append(const Array& src,           void append(const Array& src, size_t offset=0, size_t limit=ARRAY_OPTION_LIMIT_ALL) { //< zero limit means 'nothing'
                 size_t offset=0,   
                 size_t limit=ARRAY_OPTION_LIMIT_ALL) { //< negative limit means 'all'. zero limit means 'nothing'  
   
                 size_t src_count=src.count();                  size_t src_count=src.count();
                 // skip tivials                  // skip tivials
                 if(!src_count || !limit || offset>=src_count)                  if(!src_count || !limit || offset>=src_count)
                         return *this;                          return;
                 // max(limit)                  // max(limit)
                 size_t m=src_count-offset;                  size_t m=src_count-offset;
                 // fix limit                  // fix limit
                 if(limit==ARRAY_OPTION_LIMIT_ALL || limit>m)                  if(limit>m)
                         limit=m;                          limit=m;
   
                 fit(fsize-1+limit);                  fit(fsize-1+limit);
                   memcpy(felements+fsize, src.felements+offset, limit * sizeof(T));
                 T* from=&src.felements[offset];  
                 T* to=&felements[fsize];  
                 for(T* from_end=from+limit; from<from_end;)  
                         *to++=*from++;  
                 fsize+=limit;                  fsize+=limit;
                 return *this;  
         }          }
   
         /// get index-element          /// get index-element
Line 221  protected: Line 213  protected:
         }          }
   
         inline void expand() {          inline void expand() {
                 resize(fallocated>0 ? fallocated+fallocated/4+2 : 3); // 3 is PAF default, confirmed by tests                  resize(fallocated>0 ? fallocated+fallocated/2+2 : 3); // 3 is PAF default, confirmed by tests
         }          }
   
         inline void fit(size_t index){          inline void fit(size_t index){
                 if(index >= fallocated)                  if(index >= fallocated)
                         resize(max(this->fallocated + this->fallocated/4, index+1));                          resize(max(fallocated+fallocated/4, index+1));
         }          }
   
         void resize(size_t asize) {          void resize(size_t asize) {
Line 259  template<typename T> char* pa_itoa(T n, Line 251  template<typename T> char* pa_itoa(T n,
         }          }
   
         do {          do {
                 *(--pos)=(n % base) + '0';                  *(--pos)=(char)(n % base) + '0';
                 n/=base;                  n/=base;
         } while (n > 0);          } while (n > 0);
   
Line 275  template<typename T> char* pa_uitoa(T n, Line 267  template<typename T> char* pa_uitoa(T n,
         *pos='\0';          *pos='\0';
   
         do {          do {
                 *(--pos)=(n % base) + '0';                  *(--pos)=(char)(n % base) + '0';
                 n/=base;                  n/=base;
         } while (n > 0);          } while (n > 0);
   

Removed from v.1.94  
changed lines
  Added in v.1.99


E-mail: