27 #ifndef MLN_CORE_SITE_SET_P_ARRAY_HH
28 # define MLN_CORE_SITE_SET_P_ARRAY_HH
43 # include <mln/core/internal/site_set_base.hh>
44 # include <mln/core/internal/site_set_iterator_base.hh>
45 # include <mln/core/internal/pseudo_site_base.hh>
46 # include <mln/util/index.hh>
53 template <
typename P>
class p_array;
55 template <
typename S>
class p_indexed_psite;
56 template <
typename S>
class p_indexed_fwd_piter;
57 template <
typename S>
class p_indexed_bkd_piter;
65 struct site_set_< p_array<P> >
67 typedef trait::site_set::nsites::known
nsites;
68 typedef trait::site_set::bbox::unknown
bbox;
69 typedef trait::site_set::contents::growing
contents;
70 typedef trait::site_set::arity::multiple
arity;
88 typedef typename std::vector<P>::size_type
size_type;
110 p_array(
const std::vector<P>& vect);
186 template <
typename S>
203 const element&
subj_();
219 const S* target_() const;
226 operator util::
index() const;
227 operator
int() const;
228 operator
unsigned() const;
231 void update_() const;
246 template <typename S>
249 public internal::site_set_iterator_base< S,
265 bool is_valid_()
const;
290 template <
typename S>
294 p_indexed_bkd_piter<S> >
309 bool is_valid_()
const;
333 template <
typename P,
typename S>
337 template <
typename S>
341 template <
typename S,
typename A>
345 template <
typename S,
typename A>
349 template <
typename S,
typename A>
354 # ifndef MLN_INCLUDE_ONLY
359 template <
typename P>
365 template <
typename P>
367 p_array<P>::p_array(
const std::vector<P>& vect)
372 template <
typename P>
380 template <
typename P>
385 mln_precondition(p.target_() ==
this);
386 if (!
has(p.index()))
389 mln_invariant(p == static_cast<P>((*
this)[p.index()]));
393 template <
typename P>
401 template <
typename P>
409 template <
typename P>
414 mln_precondition(
has(i));
418 template <
typename P>
426 template <
typename P>
435 template <
typename P>
443 template <
typename P>
448 vect_.insert(vect_.end(),
449 other.std_vector().begin(),
450 other.std_vector().end());
454 template <
typename P>
460 mln_postcondition(this->is_empty());
463 template <
typename P>
468 mln_precondition(size >= 0);
472 template <
typename P>
477 mln_precondition(i <
nsites());
481 template <
typename P>
486 mln_precondition(i <
nsites());
490 template <
typename P>
495 mln_precondition(
has(p));
496 vect_[p.index()] = new_p;
499 template <
typename P>
504 return sizeof(*this) +
nsites() *
sizeof(P);
507 template <
typename P>
509 const std::vector<P>&
515 template <
typename P>
527 template <
typename S>
535 template <
typename S>
544 template <
typename S>
552 template <
typename S>
561 template <
typename S>
570 template <
typename S>
579 template <
typename S>
588 template <
typename S>
593 return s_ != 0 && s_->has(i_);
596 template <
typename S>
599 p_indexed_psite<S>::target_()
const
604 template <
typename S>
606 const mln_element(S)&
610 mln_invariant(p_ == (*s_)[i_]);
614 template <
typename S>
617 p_indexed_psite<S>::update_()
const
623 template <
typename S>
630 template <
typename S>
632 p_indexed_psite<S>::operator
int()
const
637 template <
typename S>
639 p_indexed_psite<S>::operator
unsigned()
const
641 mln_precondition(i_ >= 0);
648 template <
typename S>
654 template <
typename S>
661 template <
typename S>
666 mln_invariant(p_.index() >= 0);
667 return p_.index() <
int(s_->nsites());
670 template <
typename S>
675 p_.change_index(s_->nsites());
678 template <
typename S>
686 template <
typename S>
694 template <
typename S>
705 template <
typename S>
711 template <
typename S>
718 template <
typename S>
723 mln_invariant(p_.index() <
int(s_->nsites()));
724 return p_.index() >= 0;
727 template <
typename S>
735 template <
typename S>
740 p_.change_index(s_->nsites() - 1);
743 template <
typename S>
751 template <
typename S>
762 template <
typename P,
typename S>
768 template <
typename S>
769 int index_of_in(
const p_indexed_psite<S>& p,
const S& s)
771 if ((
void*)(p.target_()) == (
void*)(&s))
777 template <
typename S,
typename A>
778 int index_of_in(
const p_indexed_psite<S>& p,
const A& a)
783 template <
typename S,
typename A>
786 index_of_in(
const p_indexed_fwd_piter<S>& p,
const A& arr)
791 template <
typename S,
typename A>
794 index_of_in(
const p_indexed_bkd_piter<S>& p,
const A& arr)
799 # endif // ! MLN_INCLUDE_ONLY
804 #endif // ! MLN_CORE_SITE_SET_P_ARRAY_HH