, X Y? , .
R, Xmax-Xmin X Ymax-Ymin Y.
2D [X/R, Y/R] . .
, , 8 .
: X Y 100, R 1, 43,2, 77,1 [43,77]. [42,76] [43,76] [44,76] [42,77] [43,77] [44,77] [42,78] [43,78] [44,78] . , (, 43,9,77,9 , 1 ), 8 .
(, ?), ( ) . - O (1). O (n).
, , , ; , - . , R = 1 R R, 2D- . , , 1000 ? , , , : 8 . , R.
, , , - , X? , XR X + R. , , , , X R, / , . X, , R.
You can also go to cells smaller than R. You will have fewer candidates who cannot be close enough. For example, with R / 2, you should check 25 link lists instead of 9, but have on average (if randomly distributed) the 25/36th as many points to check. This may be a minor gain.