implementing a hash table-like data structure with floating point keys where values within a tolerance are binned together
问题 I need an associative data structure with floating point keys in which keys with nearly equal values are binned together. I'm working in C++ but language doesnt really matter. Basically my current strategy is to only handle single precision floating point numbers use an unordered_map with a custom key type define the hash function on the key type as a. given float v divide v by some tolerance, such as 0.0005, at double precision, yielding k . b. cast k to a 64 bit integer yielding ki c.