|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-10 17:51:19
JOAQUIN LOPEZ MU?Z wrote:
>
> The idea is that you can alter only some part of the
> hashing scheme and benefit of the preexisting definitions: [...]
I think I see your point. You want something like this:
template<class F> size_t hash_value( int x, F const & )
{
return x;
}
template<class F, class T> size_t hash_value( vector<T> const & v, F const &
f )
{
return for_each( v.begin(), v.end(), f ).value();
}
which, when combined with a suitable combiner 'f':
class F
{
private:
// state
public:
template<class T> void operator()( T const & t )
{
// combine state with hash_value( t, F() );
}
size_t value() const
{
// collapse state into a size_t and return it
}
};
will automatically propagate it downwards if one invokes hash_value on
vector<vector<vector<int> > >. Interesting, but overkill, IMO. ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk