I have a huge (~100,000) collection of objects over which I have no control (let's call this masterList). They are simple with several fields
public class TheirObject{
public String GUID;
public int blah1;
public string blah2;
...
}
I have another collection of tens of thousands of GUIDs (as a List of Strings) I need to, for every GUID in my list, create a sublist of TheirObjects which contain whichever TheirObjects in the masterList have the same GUIDs.
Here is some simple code That does this:
List<String> GUIDs;
List<TheirObject> masterList;
List<TheirObject> filteredList;
foreach(String GUID in GUIDs)
{
filteredList = new List<TheirObject>();
foreach(TheirObject tho in masterList)
if(tho.GUID == GUID)
filteredList.Add(tho);
//do stuff with filteredList
}
However, this takes hours! I am sure that there is a much faster way to do it, perhaphs involving sorted lists, then binary search lookups, but I can't figure out how to do it in c#. Several TheirObjects will have the same GUID in the masterList, so I don't think I can use SortedList. Help!