I have an array of n-elements by m-properties.
id1 x1 y1
id2 x2 y2
...
idn xn yn

I have a coordinate (x,y) and I want to find all the ids of elements which are to the immediate left, up, bottom and down of (x,y), that means
(x-1,y), (x,y+1), (x+1,y), (x, y-1).

How can I do this in a fast way?