http://www.perlmonks.org?node_id=884085


in reply to Re: Lookup closest hash key
in thread Lookup closest hash key

The OP is only interested in nearest in a one-dimensional space. No need for quadtrees or Voronoi diagrams. Depending how often the OP needs to query his structure, I'd either keep the numbers sorted, or just do a linear pass.