#include <types-and-constants.hh>
Public Methods | |
size_t | operator() (const file_ID_s &id) const |
This function is required because file IDs are not scalar values for which STL provides a default hashing operation.
Definition at line 300 of file types-and-constants.hh.
|
Definition at line 302 of file types-and-constants.hh.
00302 { 00303 00304 // Treat the value as a sequence of bytes, forming a hash from a 00305 // calculation borrowed from the strings hashing function in the 00306 // STL code itself. 00307 unsigned long int h = 0; 00308 char* s = (char*)&id; 00309 for (unsigned int i = 0; i < sizeof(file_ID_s); i++) { 00310 h = (5 * h) + *s; 00311 s++; 00312 } 00313 00314 return (size_t)h; 00315 } |