|
|
| version 1.64, 2004/02/11 15:33:13 | version 1.70, 2006/11/03 18:13:54 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: Array & Array_iterator classes decls. | Parser: Array & Array_iterator classes decls. |
| Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) | Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) |
| Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) | Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru) |
| */ | */ |
| Line 56 public: | Line 56 public: |
| bool adjust(size_t count) { | bool adjust(size_t count) { |
| if(!count || !limit) | if(!count || !limit) |
| return false; | return false; |
| size_t row=offset; | if(offset>=count) |
| if(row>=count) | |
| return false; | return false; |
| // max(limit) | // max(limit) |
| size_t m=reverse? | size_t m=reverse? |
| offset | offset+1 |
| :count-offset; | :count-offset; |
| if(!m) | if(!m) |
| return false; | return false; |
| Line 89 public: | Line 88 public: |
| /// append to array | /// append to array |
| Array& operator += (T src) { | Array& operator += (T src) { |
| if(is_full()) | if(is_full()) |
| expand(2); | expand(+2); |
| felements[fused++]=src; | felements[fused++]=src; |
| Line 165 public: | Line 164 public: |
| } | } |
| /// iterate over all elements | /// iterate over all elements |
| template<typename I> void for_each(bool (*callback)(T, I), I info) const { | |
| T *last=felements+fused; | |
| for(T *current=felements; current<last; current++) | |
| if(callback(*current, info)) | |
| return; | |
| } | |
| /// iterate over all elements | |
| template<typename I> void for_each_ref(void (*callback)(T&, I), I info) { | template<typename I> void for_each_ref(void (*callback)(T&, I), I info) { |
| T *last=felements+fused; | T *last=felements+fused; |
| for(T *current=felements; current<last; current++) | for(T *current=felements; current<last; current++) |
| Line 228 public: | Line 235 public: |
| } | } |
| /// quickly extracts next Array element | /// quickly extracts next Array element |
| const T next() { | T next() { |
| return *(fcurrent++); | return *(fcurrent++); |
| } | } |