Commit dfc37c34 authored by Matthieu Garrigues's avatar Matthieu Garrigues
Browse files

Rename typedef value by argument in accumulators.


	* mln/accu/bbox.hh,
	* mln/accu/count.hh,
	* mln/accu/histo.hh,
	* mln/accu/internal/base.hh,
	* mln/accu/max.hh,
	* mln/accu/max_h.hh,
	* mln/accu/mean.hh,
	* mln/accu/median.hh,
	* mln/accu/median_alt.hh,
	* mln/accu/min.hh,
	* mln/accu/min_h.hh,
	* mln/accu/nil.hh,
	* mln/accu/p.hh,
	* mln/accu/pair.hh,
	* mln/accu/sum.hh,
	* mln/accu/v.hh,
	* mln/core/concept/accumulator.hh,
	* mln/core/concept/doc/accumulator.hh,
	* mln/core/grids.hh,
	* mln/core/macros.hh: (typedef value) Rename as...
	(typedef argument) ... this.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1246 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent de861b86
2007-10-04 Matthieu Garrigues <garrigues@lrde.epita.fr>
Rename typedef value by argument in accumulators.
* mln/accu/bbox.hh,
* mln/accu/count.hh,
* mln/accu/histo.hh,
* mln/accu/internal/base.hh,
* mln/accu/max.hh,
* mln/accu/max_h.hh,
* mln/accu/mean.hh,
* mln/accu/median.hh,
* mln/accu/median_alt.hh,
* mln/accu/min.hh,
* mln/accu/min_h.hh,
* mln/accu/nil.hh,
* mln/accu/p.hh,
* mln/accu/pair.hh,
* mln/accu/sum.hh,
* mln/accu/v.hh,
* mln/core/concept/accumulator.hh,
* mln/core/concept/doc/accumulator.hh,
* mln/core/grids.hh,
* mln/core/macros.hh: (typedef value) Rename as...
(typedef argument) ... this.
2007-10-04 Simon Nivault <simon.nivault@lrde.epita.fr>
Add generic line.
......
......@@ -51,7 +51,7 @@ namespace mln
template <typename P>
struct bbox : public mln::accu::internal::base_< const box_<P>& , bbox<P> >
{
typedef P value;
typedef P argument;
typedef const box_<P>& result;
bbox();
......
......@@ -49,13 +49,13 @@ namespace mln
template <typename V>
struct count_ : public mln::accu::internal::base_< std::size_t , count_<V> >
{
typedef V value;
typedef V argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
count_();
void init();
void take(const value&);
void take(const argument&);
void take(const count_<V>& other);
std::size_t to_result() const;
......@@ -95,7 +95,7 @@ namespace mln
template <typename V>
void
count_<V>::take(const value&)
count_<V>::take(const argument&)
{
++count__;
}
......
......@@ -58,15 +58,15 @@ namespace mln
histo(const Value_Set<S>& s);
histo();
typedef mln_value(S) value;
typedef mln_value(S) argument;
typedef const std::vector<std::size_t>& result;
void take(const value& v);
void take(const argument& x);
void take(const histo<S>& other);
void untake(const value& v);
void untake(const argument& x);
void init();
std::size_t operator()(const value& v) const;
std::size_t operator()(const argument& x) const;
std::size_t operator[](std::size_t i) const;
std::size_t nvalues() const;
std::size_t sum() const;
......@@ -110,9 +110,9 @@ namespace mln
template <typename S>
void
histo<S>::take(const value& v)
histo<S>::take(const argument& x)
{
++h_[s_.index_of(v)];
++h_[s_.index_of(x)];
++sum_;
}
......@@ -127,11 +127,11 @@ namespace mln
template <typename S>
void
histo<S>::untake(const value& v)
histo<S>::untake(const argument& x)
{
mln_precondition(h_[s_.index_of(v)] > 0);
mln_precondition(h_[s_.index_of(x)] > 0);
mln_precondition(sum_ > 0);
--h_[s_.index_of(v)];
--h_[s_.index_of(x)];
--sum_;
}
......@@ -145,9 +145,9 @@ namespace mln
template <typename S>
std::size_t
histo<S>::operator()(const value& v) const
histo<S>::operator()(const argument& x) const
{
return h_[s_.index_of(v)];
return h_[s_.index_of(x)];
}
template <typename S>
......
......@@ -62,7 +62,7 @@ namespace mln
typedef R result;
operator result_() const;
protected:
base_();
};
......
......@@ -52,21 +52,21 @@ namespace mln
template <typename V>
struct max_ : public mln::accu::internal::base_< V , max_<V> >
{
typedef V value;
typedef V argument;
typedef V result;
max_();
void init();
void take_as_init(const value& v);
void take(const value& v);
void take_as_init(const argument& x);
void take(const argument& x);
void take(const max_<V>& other);
V to_result() const;
protected:
V v_;
V x_;
};
......@@ -97,37 +97,37 @@ namespace mln
void
max_<V>::init()
{
v_ = mln_min(V);
x_ = mln_min(V);
}
template <typename V>
void
max_<V>::take_as_init(const value& v)
max_<V>::take_as_init(const argument& x)
{
v_ = v;
x_ = x;
}
template <typename V>
void
max_<V>::take(const value& v)
max_<V>::take(const argument& x)
{
if (v > v_)
v_ = v;
if (x > x_)
x_ = x;
}
template <typename V>
void
max_<V>::take(const max_<V>& other)
{
if (other.v_ > v_)
v_ = other.v_;
if (other.x_ > x_)
x_ = other.x_;
}
template <typename V>
V
max_<V>::to_result() const
{
return v_;
return x_;
}
# endif // ! MLN_INCLUDE_ONLY
......
......@@ -50,21 +50,21 @@ namespace mln
template <typename S>
struct max_h : public mln::accu::internal::base_< mln_value(S) , max_h<S> >
{
typedef mln_value(S) value;
typedef value result;
typedef mln_value(S) argument;
typedef argument result;
max_h(const Value_Set<S>& s);
max_h();
void init();
void take(const value& v);
void take_as_init(const value& v);
void take(const argument& x);
void take_as_init(const argument& x);
void take(const max_h<S>& other);
void untake(const value& v);
void untake(const argument& x);
unsigned card() const { return h_.sum(); }
value to_result() const;
argument to_result() const;
const accu::histo<S>& histo() const;
......@@ -76,7 +76,7 @@ namespace mln
mutable std::size_t sum_;
mutable bool valid_;
mutable std::size_t i_; // the max index
mutable value v_; // the max value
mutable argument x_; // the max argument
// Auxiliary methods
void update_() const;
......@@ -105,15 +105,15 @@ namespace mln
template <typename S>
void
max_h<S>::take(const value& v)
max_h<S>::take(const argument& x)
{
h_.take(v);
h_.take(x);
if (h_.sum() == 1)
{
this->take_as_init(v);
this->take_as_init(x);
return;
}
if (v > v_)
if (x > x_)
{
++sum_;
valid_ = false;
......@@ -134,23 +134,23 @@ namespace mln
template <typename S>
void
max_h<S>::untake(const value& v)
max_h<S>::untake(const argument& x)
{
mln_precondition(h_(v) != 0);
h_.untake(v);
mln_precondition(h_(x) != 0);
h_.untake(x);
if (h_.sum() == 0)
{
init();
return;
}
if (v > v_)
if (x > x_)
{
mln_invariant(sum_ >= 1);
--sum_;
valid_ = false;
}
else
if (v == v_ && h_[i_] == 0)
if (x == x_ && h_[i_] == 0)
valid_ = false;
}
......@@ -173,7 +173,7 @@ namespace mln
do
--i_;
while (h_[i_] == 0);
v_ = s_[i_];
x_ = s_[i_];
}
template <typename S>
......@@ -186,7 +186,7 @@ namespace mln
if (h_[i_] != 0)
sum_ -= h_[i_];
} while (sum_ != 0);
v_ = s_[i_];
x_ = s_[i_];
}
template <typename S>
......@@ -195,29 +195,29 @@ namespace mln
{
h_.init();
sum_ = 0;
i_ = mln_min(value);
v_ = s_[i_];
i_ = mln_min(argument);
x_ = s_[i_];
valid_ = true;
}
template <typename S>
void
max_h<S>::take_as_init(const value& v)
max_h<S>::take_as_init(const argument& x)
{
h_.take(v);
h_.take(x);
sum_ = 0;
i_ = s_.index_of(v);
v_ = v;
i_ = s_.index_of(x);
x_ = x;
valid_ = true;
}
template <typename S>
typename max_h<S>::value
typename max_h<S>::argument
max_h<S>::to_result() const
{
if (! valid_)
update_();
return v_;
return x_;
}
template <typename S>
......
......@@ -60,13 +60,13 @@ namespace mln
typename M = S>
struct mean_ : public mln::accu::internal::base_< M , mean_<V,S,M> >
{
typedef V value;
typedef V argument;
typedef M result;
mean_();
void init();
void take(const value& v);
void take(const argument& x);
void take(const mean_<V,S,M>& other);
M to_result() const;
......@@ -114,10 +114,10 @@ namespace mln
}
template <typename V, typename S, typename M>
void mean_<V,S,M>::take(const value& v)
void mean_<V,S,M>::take(const argument& x)
{
count_.take(v);
sum_.take(v);
count_.take(x);
sum_.take(x);
}
template <typename V, typename S, typename M>
......
......@@ -50,20 +50,20 @@ namespace mln
template <typename S>
struct median : public mln::accu::internal::base_< mln_value(S), median<S> >
{
typedef mln_value(S) value;
typedef value result;
typedef mln_value(S) argument;
typedef argument result;
median(const Value_Set<S>& s);
median();
void init();
void take(const value& v);
void take(const argument& x);
void take(const median<S>& other);
void untake(const value& v);
void untake(const argument& x);
unsigned card() const { return h_.sum(); }
value to_result() const;
argument to_result() const;
const accu::histo<S>& histo() const;
......@@ -76,7 +76,7 @@ namespace mln
mutable bool valid_;
mutable std::size_t i_; // the median index
mutable value v_; // the median value
mutable argument x_; // the median value
// Auxiliary methods
void update_() const;
......@@ -105,13 +105,13 @@ namespace mln
template <typename S>
void
median<S>::take(const value& v)
median<S>::take(const argument& x)
{
h_.take(v);
h_.take(x);
if (v < v_)
if (x < x_)
++sum_minus_;
else if (v > v_)
else if (x > x_)
++sum_plus_;
if (valid_)
......@@ -139,20 +139,20 @@ namespace mln
template <typename S>
void
median<S>::untake(const value& v)
median<S>::untake(const argument& x)
{
mln_precondition(h_(v) != 0);
h_.untake(v);
mln_precondition(h_(x) != 0);
h_.untake(x);
if (v < v_)
if (x < x_)
--sum_minus_;
else if (v > v_)
else if (x > x_)
--sum_plus_;
if (valid_)
valid_ = false;
}
template <typename S>
void
median<S>::update_() const
......@@ -191,7 +191,7 @@ namespace mln
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
v_ = s_[i_];
x_ = s_[i_];
}
template <typename S>
......@@ -207,7 +207,7 @@ namespace mln
sum_plus_ -= h_[i_];
}
while (2 * sum_plus_ > h_.sum());
v_ = s_[i_];
x_ = s_[i_];
}
template <typename S>
......@@ -217,18 +217,18 @@ namespace mln
h_.init();
sum_minus_ = 0;
sum_plus_ = 0;
i_ = (mln_max(value) - mln_min(value)) / 2;
v_ = s_[i_];
i_ = (mln_max(argument) - mln_min(argument)) / 2;
x_ = s_[i_];
valid_ = true;
}
template <typename S>
typename median<S>::value
typename median<S>::argument
median<S>::to_result() const
{
if (! valid_)
update_();
return v_;
return x_;
}
template <typename S>
......
......@@ -50,21 +50,21 @@ namespace mln
template <typename S>
struct median_alt : : public mln::accu::internal::base_< mln_value(S), median_alt<S> >
{
typedef mln_value(S) value;
typedef mln_value(S) argument;
median_alt(const Value_Set<S>& s);
void take(const value& v);
void untake(const value& v);
void take(const argument& x);
void untake(const argument& x);
void init();
value to_result() const;
argument to_result() const;
// FIXME: remove
void debug__() const
{
std::cout << " i = " << i_
<< " v = " << v_
<< " x = " << x_
<< " s = " << sum_minus_ << " ; " << h_[i_] << " ; " << sum_plus_ << " = " << h_.sum()
<< std::endl;
}
......@@ -77,7 +77,7 @@ namespace mln
std::size_t sum_minus_, sum_plus_;
std::size_t i_; // the median index
value v_; // the median value
argument x_; // the median argument
// Auxiliary methods
void go_minus_();
......@@ -109,24 +109,24 @@ namespace mln
template <typename S>
void
median_alt<S>::take(const value& v)
median_alt<S>::take(const argument& x)
{
// update h_
h_.take(v);
h_.take(x);
// particular case:
// current state was initialization
if (h_[i_] == 0)
{
// std::cout << "init!" << std::endl;
i_ = s_.index_of(v);
v_ = v;
i_ = s_.index_of(x);
x_ = x;
return;
}
// particular case:
// the median does not change
if (v == v_)
if (x == x_)
{
// std::cout << "no change!" << std::endl;
return;
......@@ -134,14 +134,14 @@ namespace mln
// general case:
if (v < v_)
if (x < x_)
{
++sum_minus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
// v > v_
// x > x_
{
++sum_plus_;
if (2 * sum_plus_ > h_.sum())
......@@ -152,12 +152,12 @@ namespace mln
template <typename S>
void
median_alt<S>::untake(const value& v)
median_alt<S>::untake(const argument& x)
{
mln_precondition(h_(v) != 0);
mln_precondition(h_(x) != 0);
// update h_
h_.untake(v);
h_.untake(x);
// particular case:
// the only value has been removed
......@@ -168,20 +168,20 @@ namespace mln
}
// general case:
if (v < v_)
if (x < x_)
{
--sum_minus_;
if (2 * sum_plus_ > h_.sum())
go_plus_();
}
else if (v > v_)
else if (x > x_)
{
--sum_plus_;
if (2 * sum_minus_ > h_.sum())
go_minus_();
}
else
// v == v_
// x == x_
{
if (h_[i_] == 0)
{
......@@ -216,7 +216,7 @@ namespace mln
sum_minus_ -= h_[i_];
}
while (2 * sum_minus_ > h_.sum());
v_ = s_[i_];