I need to have data structure, each element in which is accessible by pair of (x,y) (like nspoint).
I can store them in NSDictionary with keys like @”8,10″, but I’m looking for more elegant and efficient solution (I don’t want to have two dimensional array cause I want to have O(1) access to elements by coordinate)
You could use a
NSValueas key (+NSValue valueWithCGPoint:see this link), might be a bit ‘lighter’. Otherwise, if the values is the x and y pair have some limit, like e.g. 256 for x, 256 for y, you could use bit masks where the first 8 bits indicate the x value and the second 8 bits the y value (since 256 = 2^8).