27 #ifndef MLN_CORE_SITE_SET_P_RUN_HH
28 # define MLN_CORE_SITE_SET_P_RUN_HH
36 # include <mln/core/internal/site_set_base.hh>
37 # include <mln/core/site_set/box.hh>
38 # include <mln/core/internal/pseudo_site_base.hh>
39 # include <mln/util/index.hh>
46 template <
typename P>
class p_run;
47 template <
typename P>
class p_run_psite;
48 template <
typename P>
class p_run_fwd_piter_;
49 template <
typename P>
class p_run_bkd_piter_;
58 struct site_set_< p_run<P> >
60 typedef trait::site_set::nsites::known
nsites;
61 typedef trait::site_set::bbox::straight
bbox;
62 typedef trait::site_set::contents::fixed
contents;
63 typedef trait::site_set::arity::unique
arity;
67 struct set_precise_unary_< op::ord, p_run<P> >
69 typedef set_precise_unary_< op::ord, p_run<P> >
ret;
70 bool strict(
const p_run<P>& lhs,
const p_run<P>&
rhs)
const;
118 void init(
const P&
start,
unsigned short len);
125 bool has(
const P&
p)
const;
134 unsigned short length()
const;
140 const P&
start()
const;
170 template <
typename P>
171 std::ostream& operator<<(std::ostream& ostr, const p_run<P>& r);
177 template <
typename P>
224 # ifndef MLN_INCLUDE_ONLY
226 template <
typename P>
233 template <
typename P>
237 mln_precondition(len != 0);
241 template <
typename P>
246 mln_precondition(
cut_(end) ==
cut_(start));
247 mln_precondition(end.last_coord() >= start.last_coord());
248 len_ = end.last_coord() - start.last_coord() + 1;
251 template <
typename P>
256 mln_precondition(len != 0);
261 template <
typename P>
269 template <
typename P>
278 template <
typename P>
283 mln_precondition(p.target_() ==
this);
284 if (p.index() < 0 ||
unsigned(p.index()) >= len_)
287 mln_invariant(p.to_site() == (*this)[p.index()]);
291 template <
typename P>
296 mln_precondition(is_valid());
300 p.last_coord() >= start_.last_coord() &&
301 p.last_coord() < start_.last_coord() + len_;
304 template <
typename P>
312 template <
typename P>
317 mln_precondition(is_valid());
321 template <
typename P>
326 mln_precondition(is_valid());
330 template <
typename P>
335 mln_precondition(is_valid());
336 mln_precondition(i < len_);
342 template <
typename P>
350 template <
typename P>
356 p.last_coord() += len_ - 1;
360 template <
typename P>
365 return sizeof(*this);
368 template <
typename P>
369 std::ostream& operator<<(std::ostream& ostr, const p_run<P>& r)
371 ostr <<
'(' << r.start() <<
", " << r.length() <<
')';
379 template <
typename P>
387 template <
typename P>
394 p_.last_coord() += i_;
397 template <
typename P>
402 return run_ != 0 && run_->has_index(i_);
405 template <
typename P>
413 template <
typename P>
418 p_.last_coord() += (i - i_);
422 template <
typename P>
428 p_.last_coord() -= 1;
431 template <
typename P>
437 p_.last_coord() += 1;
440 template <
typename P>
443 p_run_psite<P>::target_()
const
448 template <
typename P>
458 template <
typename P>
466 template <
typename P>
473 template <
typename P>
478 mln_precondition(run_ != 0);
485 template <
typename P>
488 set_precise_unary_< op::ord, p_run<P> >::strict(
const p_run<P>& lhs,
const p_run<P>&
rhs)
const
495 # endif // ! MLN_INCLUDE_ONLY
500 # include <mln/core/site_set/p_run_piter.hh>
503 #endif // ! MLN_CORE_SITE_SET_P_RUN_HH