spot/src/misc/hash.hh
Alexandre Duret-Lutz f0de38680a * src/tgba/state.hh (state::hash): New method.
(state_ptr_equal, state_ptr_hash): New functors.
* src/tgba/statebdd.hh, src/tgba/statebdd.cc (state_bdd::hash):
New method.
* src/tgba/tgbaexplicit.hh, src/tgba/tgbaexplicit.cc
(state_explicit::hash): New method.
(ns_map, sn_map): Use Sgi::hash_map instead of std::map.
* src/tgba/tgbaproduct.hh, src/tgba/tgbaproduct.cc
(state_product::hash): New method.
* src/tgba/tgbatba.cc (state_tba_proxy::hash): New method.
* src/tgbaalgos/lbtt.cc (acp_seen, todo_set, seen_map): Redefine
using Sgi::hash_map or Sgi::hash_set.
(lbtt_reachable): Don't erase a key that is pointed to by an
iterator.
* src/tgbaalgos/reachiter.cc
(tgba_reachable_iterator::~tgba_reachable_iterator): Likewise.
* src/tgbaalgos/magic.cc (magic_search::~magic_search()): Likewise.
* src/tgbaalgos/magic.hh (hash_type): Redefine using Sgi::hash_map.
* src/tgbaalgos/reachiter.hh (seen_map): Redefine using Sgi::hash_map.
* iface/gspn/gspn.cc (state_gspn::hash): New method.
* src/misc/hash.hh (string_hash): New functor.
2003-08-29 15:54:31 +00:00

57 lines
1.3 KiB
C++

#ifndef SPOT_MISC_HASH_HH
# define SPOT_MISC_HASH_HH
# include <string>
// See the G++ FAQ for details about the following.
# ifdef __GNUC__
# if __GNUC__ < 3
# include <hash_map.h>
# include <hash_set.h>
namespace Sgi
{ // inherit globals
using ::hash_map;
using ::hash_set;
using ::hash;
};
# else
# include <ext/hash_map>
# include <ext/hash_set>
# if __GNUC_MINOR__ == 0
namespace Sgi = std; // GCC 3.0
# else
namespace Sgi = ::__gnu_cxx; // GCC 3.1 and later
# endif
# endif
# else // ... there are other compilers, right?
# include <hash_map>
# include <hash_set>
namespace Sgi = std;
# endif
namespace spot
{
/// A hash function for pointers.
template <class T>
struct ptr_hash
{
size_t operator()(const T* p) const
{
return reinterpret_cast<const char*>(p) - static_cast<const char*>(0);
}
};
/// A hash function for strings.
struct string_hash : Sgi::hash<const char*>
{
size_t operator()(const std::string& s) const
{
// We are living dangerously. Be sure to call operator()
// from the super-class, not this one.
return Sgi::hash<const char*>::operator()(s.c_str());
}
};
}
#endif // SPOT_MISC_HASH_HH