ltl: get rid of formula_ptr_hash

* src/ltlast/formula.hh: Specialize std::hash<>.
* src/ltlvisit/contain.hh, src/ltlvisit/relabel.cc,
src/tgba/taatgba.hh, src/tgbaalgos/ltl2tgba_fm.cc: Do
not pass formula_ptr_hash to unordered_map.
This commit is contained in:
Alexandre Duret-Lutz 2014-10-26 21:42:28 +01:00
parent 3d9ffaec83
commit c189875daf
5 changed files with 33 additions and 50 deletions

View file

@ -501,31 +501,6 @@ namespace spot
}
};
/// \ingroup ltl_essentials
/// \ingroup hash_funcs
/// \brief Hash Function for <code>const formula*</code>.
///
/// This is meant to be used as a hash functor for
/// \c unordered_map whose key are of type <code>const formula*</code>.
///
/// For instance here is how one could declare
/// a map of \c const::formula*.
/// \code
/// // Remember how many times each formula has been seen.
/// std::unordered_map<const spot::ltl::formula*, int,
/// const spot::ltl::formula_ptr_hash> seen;
/// \endcode
struct formula_ptr_hash:
public std::unary_function<const formula*, size_t>
{
size_t
operator()(const formula* that) const
{
assert(that);
return that->hash();
}
};
/// Print the properties of formula \a f on stream \a out.
SPOT_API
std::ostream& print_formula_props(std::ostream& out,
@ -538,4 +513,19 @@ namespace spot
}
}
#ifndef SWIG
namespace std
{
template <>
struct hash<const spot::ltl::formula*>
{
size_t operator()(const spot::ltl::formula* x) const noexcept
{
assert(x);
return x->hash();
}
};
}
#endif
#endif // SPOT_LTLAST_FORMULA_HH