author | Michael Krelin <hacker@klever.net> | 2014-03-05 21:13:36 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2014-03-05 21:13:36 (UTC) |
commit | 00cf4285fb0539873754f23a654b9cd13ae29af4 (patch) (side-by-side diff) | |
tree | 67c80f2ea5c548d8ff06e9997fd00ddff1db3a50 /include/opkele/iterator.h | |
parent | 5b6756787fb7005b98ad43fb875fbaa0d33a5e88 (diff) | |
download | libopkele-00cf4285fb0539873754f23a654b9cd13ae29af4.zip libopkele-00cf4285fb0539873754f23a654b9cd13ae29af4.tar.gz libopkele-00cf4285fb0539873754f23a654b9cd13ae29af4.tar.bz2 |
remove post-increment implementation as it is awfully invalid
as per github issue #5
-rw-r--r-- | include/opkele/iterator.h | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/include/opkele/iterator.h b/include/opkele/iterator.h index 94da7e4..9e5b196 100644 --- a/include/opkele/iterator.h +++ b/include/opkele/iterator.h @@ -98,119 +98,114 @@ namespace opkele { template<typename IT> forward_iterator_proxy(const IT& i) : I(new forward_iterator_proxy_impl<IT>(i)) { } forward_iterator_proxy(const forward_iterator_proxy<T,TR,TP>& x) : I(x.I->dup()) { } ~forward_iterator_proxy() { delete I; } forward_iterator_proxy& operator=(const forward_iterator_proxy<T,TR,TP>& x) { delete I; I = x.I->dup(); return *this; } bool operator==(const forward_iterator_proxy<T,TR,TP>& x) const { return (*I)==(*(x.I)); } bool operator!=(const forward_iterator_proxy<T,TR,TP>& x) const { return (*I)!=(*(x.I)); } TR operator*() const { return **I; } TP operator->() const { return I->operator->(); } forward_iterator_proxy<T,TR,TP>& operator++() { I->advance(); return *this; } forward_iterator_proxy<T,TR,TP>& operator++(int) { forward_iterator_proxy<T,TR,TP> rv(*this); I->advance(); return rv; } }; template<typename IT> class basic_filterator : public iterator< typename IT::iterator_category, typename IT::value_type, typename IT::difference_type, typename IT::pointer, typename IT::reference> { public: IT it; IT ei; bool empty; basic_filterator() : empty(true) { } basic_filterator(const IT& _bi,const IT& _ei) : it(_bi), ei(_ei) { empty = (it==ei); } basic_filterator(const basic_filterator<IT>& x) : it(x.it), ei(x.ei), empty(x.empty) { } virtual ~basic_filterator() { } bool operator==(const basic_filterator<IT>& x) const { return empty?x.empty:(it==x.it); } bool operator!=(const basic_filterator<IT>& x) const { return empty!=x.empty || it!=x.it; } typename IT::reference operator*() const { assert(!empty); return *it; } typename IT::pointer operator->() const { assert(!empty); return it.operator->(); } basic_filterator<IT>& operator++() { bool found = false; for(++it;!(it==ei || (found=is_interesting()));++it) ; if(!found) empty=true; return *this; } - basic_filterator<IT> operator++(int) { - basic_filterator<IT> rv(*this); - ++(*this); - return rv; - } void prepare() { bool found = false; for(;!(it==ei || (found=is_interesting()));++it) ; if(!found) empty = true; } virtual bool is_interesting() const = 0; }; template<typename IT,typename T=typename IT::value_type::first_type,typename TR=T&,typename TP=T*> class map_keys_iterator : public iterator< typename IT::iterator_category, T,void,TP,TR> { public: typedef map_keys_iterator<IT,T,TR,TP> self_type; IT it; IT ei; bool empty; map_keys_iterator() : empty(true) { } map_keys_iterator(const IT& _bi, const IT& _ei) : it(_bi), ei(_ei) { empty = (it==ei); } map_keys_iterator(const self_type& x) : it(x.it), ei(x.ei), empty(x.empty) { } bool operator==(const self_type& x) const { return empty?x.empty:(it==x.it); } bool operator!=(const self_type& x) const { return empty!=x.empty || it!=x.it; } TR operator*() const { assert(!empty); return it->first; } TP operator->() const { assert(!empty); return &(it->first); } self_type& operator++() { assert(!empty); empty=((++it)==ei); return *this; } self_type operator++(int) { self_type rv(*this); ++(*this); return rv; } }; } } #endif /* __OPKELE_ITERATOR_H */ |