yu******@gmail.com wrote:
>
I am wondering what is the hash function that is used in
hash_map/hash_set. Can I replace it with my own
hash function? Any comments on this?
By default, hash_map and hash_set use
namespace std {
namespace tr1 {
template <class Tystruct hash
: unary_function<Ty, size_t>
{
size_t operator()(Ty val) const;
};
} }
This template is specialized for bool, all integer types, all
floating-point types, pointers, std::string, and std::wstring.
You can specialize it for any of your own types.
You can also use your own type as an argument to hash_map or hash_set.
For details, see section 5.6 of my book, "The C++ Standard Library
Extensions: a Tutorial and Reference."