Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef SELECTED_ATOM_ITERATOR_H
00036 #define SELECTED_ATOM_ITERATOR_H
00037
00038 #include <ESBTL/iterators.h>
00039
00040
00041
00042
00043 namespace ESBTL{
00044
00045
00046
00047
00048
00059 template <class Model,class Subset_functor,bool is_const>
00060 class Selected_atom_iterator:
00061 public boost::iterator_facade<
00062 Selected_atom_iterator<Model,Subset_functor,is_const>,
00063 typename internal::do_add_const<typename Model::System::Atom,is_const>::type,
00064 boost::forward_traversal_tag>
00065 {
00066 private:
00067 typedef typename Model::System::Atom Atom;
00068 typedef typename internal::Atoms_iterator_from_model<Model,is_const> Base_iterator;
00069
00070 public:
00071
00076 Selected_atom_iterator(Base_iterator it,const Subset_functor& functor):atom_iterator(it),keep(functor)
00077 {if (!atom_iterator.is_end() && !keep(*atom_iterator)) increment();}
00078
00079 Selected_atom_iterator(Base_iterator it):atom_iterator(it)
00080 {if (!atom_iterator.is_end() && !keep(*atom_iterator)) increment();}
00081
00082 private:
00083 friend class boost::iterator_core_access;
00084
00085 void increment(){
00086 do{
00087 ++atom_iterator;
00088 }
00089 while(!atom_iterator.is_end() && !keep(*atom_iterator));
00090 }
00091
00092 bool equal(Selected_atom_iterator const& other) const{
00093 return atom_iterator==other.atom_iterator;
00094 }
00095
00096 typename internal::do_add_const_to_ref<Atom,is_const>::type dereference() const {
00097 return *atom_iterator;
00098 }
00099
00100
00101 Base_iterator atom_iterator;
00102 Subset_functor keep;
00103 };
00104
00105
00107 template <class Model,class Subset_functor,bool is_const>
00108 Selected_atom_iterator<Model,Subset_functor,is_const>
00109 make_selected_atom_iterator(internal::Atoms_iterator_from_model<Model,is_const> iterator,const Subset_functor& functor){
00110 return Selected_atom_iterator<Model,Subset_functor,is_const> (iterator,functor);
00111 }
00112
00114 template <class Subset_functor,class Model,bool is_const>
00115 Selected_atom_iterator<Model,Subset_functor,is_const>
00116 make_selected_atom_iterator(internal::Atoms_iterator_from_model<Model,is_const> iterator){
00117 return Selected_atom_iterator<Model,Subset_functor,is_const> (iterator);
00118 }
00119
00120 }
00121
00122 #endif //SELECTED_ATOM_ITERATOR_H