* mln/world/kn/accu/max_interval.hh,
* mln/world/kn/accu/min_interval.hh: Here.
---
milena/ChangeLog | 7 +++++++
milena/mln/world/kn/accu/max_interval.hh | 6 ++++++
milena/mln/world/kn/accu/min_interval.hh | 5 +++++
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b3bc9f7..d925cb5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,12 @@
2012-11-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add preconditions.
+
+ * mln/world/kn/accu/max_interval.hh,
+ * mln/world/kn/accu/min_interval.hh: Here.
+
+2012-11-01 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Move files to proper directories.
* mln/accu/stat/median_few.hh,
diff --git a/milena/mln/world/kn/accu/max_interval.hh
b/milena/mln/world/kn/accu/max_interval.hh
index e53be7e..dc183ef 100644
--- a/milena/mln/world/kn/accu/max_interval.hh
+++ b/milena/mln/world/kn/accu/max_interval.hh
@@ -147,6 +147,7 @@ namespace mln
{
mlc_converts_to(U,T)::check();
mlc_converts_to(V,T)::check();
+ mln_precondition(first <= last);
inter_ = value::interval<T>(first, last);
init();
}
@@ -164,6 +165,7 @@ namespace mln
void
max_interval<T>::take_as_init_(const argument& t)
{
+ mln_precondition(inter_.has(t));
t_ = t;
}
@@ -172,6 +174,7 @@ namespace mln
void
max_interval<T>::take(const argument& t)
{
+ mln_precondition(inter_.has(t));
if (t > t_)
t_ = t;
}
@@ -181,6 +184,8 @@ namespace mln
void
max_interval<T>::take(const max_interval<T>& other)
{
+ mln_precondition(inter_.first() <= other.inter_.first());
+ mln_precondition(inter_.last() >= other.inter_.last());
if (other.t_ > t_)
t_ = other.t_;
}
@@ -190,6 +195,7 @@ namespace mln
void
max_interval<T>::set_value(const T& t)
{
+ mln_precondition(inter_.has(t));
t_ = t;
}
diff --git a/milena/mln/world/kn/accu/min_interval.hh
b/milena/mln/world/kn/accu/min_interval.hh
index 7081a07..e95fe34 100644
--- a/milena/mln/world/kn/accu/min_interval.hh
+++ b/milena/mln/world/kn/accu/min_interval.hh
@@ -145,6 +145,7 @@ namespace mln
{
mlc_converts_to(U,T)::check();
mlc_converts_to(V,T)::check();
+ mln_precondition(first <= last);
inter_ = value::interval<T>(first, last);
init();
}
@@ -161,6 +162,7 @@ namespace mln
inline
void min_interval<T>::take_as_init_(const argument& t)
{
+ mln_precondition(inter_.has(t));
t_ = t;
}
@@ -168,6 +170,7 @@ namespace mln
inline
void min_interval<T>::take(const argument& t)
{
+ mln_precondition(inter_.has(t));
if (t < t_)
t_ = t;
}
@@ -177,6 +180,8 @@ namespace mln
void
min_interval<T>::take(const min_interval<T>& other)
{
+ mln_precondition(inter_.first() <= other.inter_.first());
+ mln_precondition(inter_.last() >= other.inter_.last());
if (other.t_ < t_)
t_ = other.t_;
}
--
1.7.2.5
Show replies by date