hash function providing unique uint from an integer coordinate pair

前端 未结 11 1961
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 10:09

The problem in general: I have a big 2d point space, sparsely populated with dots. Think of it as a big white canvas sprinkled with black dots. I have to it

11条回答
  •  甜味超标
    2020-12-13 10:46

    Like Emil, but handles 16-bit overflows in x in a way that produces fewer collisions, and takes fewer instructions to compute:

    hash = ( y << 16 ) ^ x;
    

提交回复
热议问题