26 #ifndef MLN_CORE_SITE_SET_P_SET_OF_HH
27 # define MLN_CORE_SITE_SET_P_SET_OF_HH
36 # include <mln/core/site_set/p_double.hh>
37 # include <mln/core/internal/site_set_base.hh>
38 # include <mln/core/internal/site_set_impl.hh>
39 # include <mln/util/set.hh>
47 template <
typename S>
class p_set_of;
54 struct site_set_< p_set_of<S> >
56 typedef mln_trait_site_set_nsites(S) nsites;
57 typedef mln_trait_site_set_bbox(S) bbox;
58 typedef trait::site_set::contents::growing contents;
59 typedef trait::site_set::arity::multiple arity;
71 class p_set_of : public internal::site_set_base_< mln_site(S),
74 private mlc_is_a(S, Site_Set)::check_t
76 typedef p_set_of<S> self_;
77 typedef util::set<S> set_;
85 typedef p_double_psite<self_, element> psite;
88 typedef p_double_piter<self_,
90 mln_fwd_piter(S)> fwd_piter;
93 typedef p_double_piter<self_,
95 mln_bkd_piter(S)> bkd_piter;
98 typedef fwd_piter piter;
106 bool has(
const psite& p)
const;
109 bool is_valid()
const;
116 void insert(
const S& s);
120 const S& operator[](
unsigned i)
const;
123 unsigned nelements()
const;
131 std::size_t memory_size()
const;
134 const util::set<S>& set_hook_()
const;
138 const util::set<S>& set_1_()
const;
139 template <
typename I>
140 const S& set_2_(
const I& it)
const;
150 template <
typename S>
151 std::ostream& operator<<(std::ostream& ostr, const p_set_of<S>& s);
156 # ifndef MLN_INCLUDE_ONLY
158 template <
typename S>
160 p_set_of<S>::p_set_of()
164 template <
typename S>
167 p_set_of<S>::has(
const psite& p)
const
169 return p.index() < s_.nelements() && s_[p.index()].has(p.p());
172 template <
typename S>
175 p_set_of<S>::is_valid()
const
180 template <
typename S>
183 p_set_of<S>::insert(
const S& s)
185 mln_precondition(s.is_valid());
187 this->update_nsites_(s);
188 this->update_bbox_(s);
191 template <
typename S>
194 p_set_of<S>::operator[](
unsigned i)
const
196 mln_precondition(i < s_.nelements());
200 template <
typename S>
203 p_set_of<S>::nelements()
const
205 return s_.nelements();
208 template <
typename S>
214 mln_postcondition(this->is_empty());
217 template <
typename S>
220 p_set_of<S>::memory_size()
const
222 return s_.memory_size();
225 template <
typename S>
228 p_set_of<S>::set_hook_()
const
233 template <
typename S>
236 p_set_of<S>::set_1_()
const
241 template <
typename S>
242 template <
typename I>
245 p_set_of<S>::set_2_(
const I& it)
const
251 template <
typename S>
252 std::ostream& operator<<(std::ostream& ostr, const p_set_of<S>& s)
254 return ostr << s.set_hook_();
257 # endif // ! MLN_INCLUDE_ONLY
262 #endif // ! MLN_CORE_SITE_SET_P_SET_OF_HH