21 Aug
2010
21 Aug
'10
7:41 a.m.
FYI, the implementation of ar_hash doesn't look quite right
On Fri, Aug 20, 2010 at 7:52 PM, Tim Moore
struct ar_hash : std::unary_function
{ std::size_t operator()(small_array const& x) const { int init = 0; return boost::hash_value(std::accumulate(x.begin(), x.end(), init)); } };
Consider inputs: small_array one = {1,2,3,4}; small_array two = {1,2,2,5}; The sum of each is 10, which will result in the same hash. This will probably cause hash collisions and result in poorer performance than combining each hash value. Replacing the implementation with the following should give better results: return boost::hash_range(x.begin(), x.end()); Nate