So I have an unsorted data set with x and y float coordinates as keys. The data is in a txt file. It looks like this:x,y,data;x2,y2,data2;etcI need to retrieve all data in a specific rectangular area multiple times with different areas each time. What would be the fastest algorithm to do this. (I'm working in C#)My current solution looks like this:Create a sorted dictionary(dic1) with X key and y valuesCreate a sorted dictionary(dic2) with y key and data valuesCreate a list(list1) and add all X in dic1 that are between max-X and min-X(based on the area wanted)Create another list(list2) and for each item in list1, if the item has a y between max-Y and min-Y (based on the area wanted) then add to list2.List2 is our set of points in the target areaAnything faster?
Fastest way to retrieve data in an area based on xy coordinates?
c#;algorithms
What you are looking for is called a Spatial index.In your case, basic grid or quadtree should be enough.