26 #ifndef MLN_CORE_SITE_SET_P_DOUBLE_HH
27 # define MLN_CORE_SITE_SET_P_DOUBLE_HH
38 # include <mln/core/internal/pseudo_site_base.hh>
39 # include <mln/core/internal/site_set_iterator_base.hh>
47 template <
typename S,
typename Sp>
48 class p_double_psite :
public internal::pseudo_site_base_< const mln_psite(Sp)&,
49 p_double_psite<S,Sp> >
58 const S* target_()
const;
60 void change_target(
const S& newtarget);
62 bool is_valid()
const;
64 unsigned index()
const;
65 const mln_psite(Sp)& p()
const;
67 void change_i(
unsigned i);
69 void change_p(
const mln_psite(Sp)& p);
72 const mln_psite(Sp)& subj_();
78 mutable mln_psite(Sp) p_;
85 template <typename S, typename I1, typename I2>
88 public internal::site_set_iterator_base< S,
89 p_double_piter<S,I1,I2> >
91 typedef p_double_piter<S,I1,I2> self_;
92 typedef internal::site_set_iterator_base<S,self_> super_;
99 p_double_piter(
const S& s);
102 void change_target(
const S& newtarget);
105 bool is_valid_()
const;
131 # ifndef MLN_INCLUDE_ONLY
136 template <
typename S,
typename Sp>
138 p_double_psite<S,Sp>::p_double_psite()
142 template <
typename S,
typename Sp>
145 p_double_psite<S,Sp>::subj_()
150 template <
typename S,
typename Sp>
153 p_double_psite<S,Sp>::target_()
const
158 template <
typename S,
typename Sp>
161 p_double_psite<S,Sp>::change_target(
const S& s)
166 template <
typename S,
typename Sp>
169 p_double_psite<S,Sp>::is_valid()
const
171 return s_ != 0 && p_.is_valid();
174 template <
typename S,
typename Sp>
177 p_double_psite<S,Sp>::index()
const
182 template <
typename S,
typename Sp>
185 p_double_psite<S,Sp>::p()
const
190 template <
typename S,
typename Sp>
193 p_double_psite<S,Sp>::change_i(
unsigned i)
198 template <
typename S,
typename Sp>
201 p_double_psite<S,Sp>::change_p(
const mln_psite(Sp)& p)
209 template <
typename S,
typename I1,
typename I2>
211 p_double_piter<S,I1,I2>::p_double_piter()
215 template <
typename S,
typename I1,
typename I2>
217 p_double_piter<S,I1,I2>::p_double_piter(
const S& s)
219 this->change_target(s);
222 template <
typename S,
typename I1,
typename I2>
225 p_double_piter<S,I1,I2>::change_target(
const S& newtarget)
227 this->super_::change_target(newtarget);
228 i1_.change_target(newtarget.set_1_());
232 template <
typename S,
typename I1,
typename I2>
235 p_double_piter<S,I1,I2>::is_valid_()
const
237 return i2_.is_valid();
240 template <
typename S,
typename I1,
typename I2>
243 p_double_piter<S,I1,I2>::invalidate_()
248 template <
typename S,
typename I1,
typename I2>
251 p_double_piter<S,I1,I2>::start_()
256 i2_.change_target(s_->set_2_(i1_));
258 if (! i2_.is_valid())
262 p_.change_i(i1_.index_());
268 mln_postcondition(
implies(i2_.is_valid(), i1_.is_valid()));
271 template <
typename S,
typename I1,
typename I2>
274 p_double_piter<S,I1,I2>::next_()
277 if (! i2_.is_valid())
281 mln_postcondition(
implies(i2_.is_valid(), i1_.is_valid()));
284 template <
typename S,
typename I1,
typename I2>
287 p_double_piter<S,I1,I2>::progress_()
291 while (! i2_.is_valid() && i1_.is_valid())
294 if (! i1_.is_valid())
300 i2_.change_target(s_->set_2_(i1_));
305 p_.change_i(i1_.index_());
310 # endif // ! MLN_INCLUDE_ONLY
315 #endif // ! MLN_CORE_SITE_SET_P_DOUBLE_HH