26 #ifndef MLN_UTIL_LAZY_SET_HH
27 # define MLN_UTIL_LAZY_SET_HH
39 # include <mln/core/internal/force_exact.hh>
40 # include <mln/core/contract.hh>
103 const E&
element(
unsigned i)
const;
126 bool has(
const E& elt)
const;
152 const std::vector<E>&
vect()
const;
179 mutable std::vector<E> v_;
192 void update_()
const;
195 mutable bool needs_update_;
202 # ifndef MLN_INCLUDE_ONLY
204 template <
typename E>
208 needs_update_ =
false;
212 template <
typename E>
217 mln_assertion(!mode_);
219 if (needs_update_ ==
false)
220 needs_update_ =
true;
221 return mln::internal::force_exact< lazy_set_<E> >(*this);
224 template <
typename E>
229 mln_assertion(!mode_);
231 std::remove(s_.begin(), s_.end(), elt);
232 if (needs_update_ ==
false)
233 needs_update_ =
true;
234 return mln::internal::force_exact< lazy_set_<E> >(*this);
237 template <
typename E>
242 assert((!mode_ && i < s_.size())
250 template <
typename E>
258 template <
typename E>
269 template <
typename E>
275 return s_.find(elt) != s_.end();
277 return v_.find(elt) != v_.end();
280 template <
typename E>
288 template <
typename E>
295 needs_update_ =
false;
297 mln_postcondition(is_empty());
300 template <
typename E>
302 const std::vector<E>&
311 template <
typename E>
326 mln_assertion(s_.size() == 0);
327 for (
typename std::vector<E>::iterator it = v_.begin();
328 it != v_.end(); it++)
330 needs_update_ =
false;
336 template <
typename E>
344 template <
typename E>
347 lazy_set_<E>::update_()
const
349 mln_precondition(needs_update_ && !mode_);
351 std::copy(s_.begin(), s_.end(), std::back_inserter(v_));
355 needs_update_ =
false;
371 # endif // ! MLN_INCLUDE_ONLY
378 #endif // ! MLN_UTIL_LAZY_SET_HH