--- parser3/src/include/pa_array.h 2003/07/24 11:31:21 1.59 +++ parser3/src/include/pa_array.h 2006/11/03 18:13:54 1.70 @@ -1,14 +1,14 @@ /** @file Parser: Array & Array_iterator classes decls. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #ifndef PA_ARRAY_H #define PA_ARRAY_H -static const char* IDENT_ARRAY_Y="$Date: 2003/07/24 11:31:21 $"; +static const char * const IDENT_ARRAY_Y="$Date: 2006/11/03 18:13:54 $"; // includes @@ -56,12 +56,11 @@ public: bool adjust(size_t count) { if(!count || !limit) return false; - size_t row=offset; - if(row>=count) + if(offset>=count) return false; // max(limit) size_t m=reverse? - offset + offset+1 :count-offset; if(!m) return false; @@ -89,7 +88,7 @@ public: /// append to array Array& operator += (T src) { if(is_full()) - expand(2); + expand(+2); felements[fused++]=src; @@ -139,19 +138,19 @@ public: /// get index-element T get(size_t index) const { - assert(index>=0 && index=0 && index=0 && index void for_each(bool (*callback)(T, I), I info) const { + T *last=felements+fused; + for(T *current=felements; current void for_each_ref(void (*callback)(T&, I), I info) { + T *last=felements+fused; + for(T *current=felements; current T first_that(bool (*callback)(T, I), I info) const { T *last=felements+fused; @@ -221,44 +235,9 @@ public: } /// quickly extracts next Array element - const T next() { - return *(fcurrent++); - } - -}; -/* -/** Nonconst array iterator, usage: - @code - // Array a; - for(Array_iterator i(a); i.has_next(); ) { - T& element=i.next(); - ... - } - @endcode -* / -template class Array_modifing_iterator { - - Array& farray; - T *fcurrent; - T *flast; - -public: - - Array_modifing_iterator(Array& aarray): farray(aarray) { - fcurrent=farray.felements; - flast=farray.felements+farray.count(); - } - - /// there are still elements - bool has_next() { - return fcurrent