This commit is contained in:
Tiago Gomes 2013-02-08 00:56:42 +00:00
parent c41b6d80b6
commit 98842dca74
3 changed files with 17 additions and 34 deletions

View File

@ -43,18 +43,13 @@ inline size_t hash_combine (size_t seed, const T& v)
namespace std {
template <typename T1, typename T2> struct hash<std::pair<T1,T2>>
{
size_t operator() (const std::pair<T1,T2>& p) const
{
template <typename T1, typename T2> struct hash<std::pair<T1,T2>> {
size_t operator() (const std::pair<T1,T2>& p) const {
return horus::hash_combine (std::hash<T1>()(p.first), p.second);
}
};
}};
template <typename T> struct hash<std::vector<T>>
{
size_t operator() (const std::vector<T>& vec) const
{
template <typename T> struct hash<std::vector<T>> {
size_t operator() (const std::vector<T>& vec) const {
size_t h = 0;
typename std::vector<T>::const_iterator first = vec.begin();
typename std::vector<T>::const_iterator last = vec.end();
@ -62,8 +57,7 @@ template <typename T> struct hash<std::vector<T>>
h = horus::hash_combine (h, *first);
}
return h;
}
};
}};
} // namespace std

View File

@ -77,14 +77,12 @@ namespace std {
template <> struct hash<horus::Symbol> {
size_t operator() (const horus::Symbol& s) const {
return std::hash<unsigned>() (s);
}
};
}};
template <> struct hash<horus::LogVar> {
size_t operator() (const horus::LogVar& X) const {
return std::hash<unsigned>() (X);
}
};
}};
} // namespace std

View File

@ -402,35 +402,26 @@ operator<< (std::ostream& os, const std::vector<T>& v)
namespace func_obj {
template<typename T>
struct max : public std::binary_function<T, T, T>
{
T operator() (const T& x, const T& y) const
{
struct max : public std::binary_function<T, T, T> {
T operator() (const T& x, const T& y) const {
return x < y ? y : x;
}
};
}};
template <typename T>
struct abs_diff : public std::binary_function<T, T, T>
{
T operator() (const T& x, const T& y) const
{
struct abs_diff : public std::binary_function<T, T, T> {
T operator() (const T& x, const T& y) const {
return std::abs (x - y);
}
};
}};
template <typename T>
struct abs_diff_exp : public std::binary_function<T, T, T>
{
T operator() (const T& x, const T& y) const
{
struct abs_diff_exp : public std::binary_function<T, T, T> {
T operator() (const T& x, const T& y) const {
return std::abs (std::exp (x) - std::exp (y));
}
};
}};
} // namespace func_obj