27 #ifndef MLN_CORE_SITE_SET_P_SET_OF_HH
28 # define MLN_CORE_SITE_SET_P_SET_OF_HH
37 # include <mln/core/site_set/p_double.hh>
38 # include <mln/core/internal/site_set_base.hh>
39 # include <mln/core/internal/site_set_impl.hh>
40 # include <mln/util/set.hh>
48 template <
typename S>
class p_set_of;
55 struct site_set_< p_set_of<S> >
57 typedef mln_trait_site_set_nsites(S)
nsites;
58 typedef mln_trait_site_set_bbox(S)
bbox;
72 class
p_set_of : public internal::site_set_base_< mln_site(S),
74 public internal::site_set_impl<S>,
75 private mlc_is_a(S,
Site_Set)::check_t
107 bool has(
const psite&
p)
const;
110 bool is_valid()
const;
117 void insert(
const S& s);
121 const S& operator[](
unsigned i)
const;
124 unsigned nelements()
const;
132 std::size_t memory_size()
const;
141 template <
typename I>
142 const S& set_2_(
const I& it)
const;
153 template <
typename S>
154 std::ostream& operator<<(std::ostream& ostr, const p_set_of<S>& s);
159 # ifndef MLN_INCLUDE_ONLY
161 template <
typename S>
167 template <
typename S>
170 p_set_of<S>::has(
const psite&
p)
const
172 return p.index() < s_.nelements() && s_[p.index()].has(p.p());
175 template <
typename S>
178 p_set_of<S>::is_valid()
const
183 template <
typename S>
186 p_set_of<S>::insert(
const S& s)
188 mln_precondition(s.is_valid());
190 this->update_nsites_(s);
191 this->update_bbox_(s);
194 template <
typename S>
197 p_set_of<S>::operator[](
unsigned i)
const
199 mln_precondition(i < s_.nelements());
203 template <
typename S>
206 p_set_of<S>::nelements()
const
208 return s_.nelements();
211 template <
typename S>
217 mln_postcondition(this->is_empty());
220 template <
typename S>
223 p_set_of<S>::memory_size()
const
225 return s_.memory_size();
228 template <
typename S>
231 p_set_of<S>::set_hook_()
const
236 template <
typename S>
239 p_set_of<S>::set_1_()
const
244 template <
typename S>
245 template <
typename I>
248 p_set_of<S>::set_2_(
const I& it)
const
254 template <
typename S>
255 std::ostream& operator<<(std::ostream& ostr, const p_set_of<S>& s)
257 return ostr << s.set_hook_();
260 # endif // ! MLN_INCLUDE_ONLY
265 #endif // ! MLN_CORE_SITE_SET_P_SET_OF_HH