Adding another answer to accomodate some additional NFRs that have come up in the comments:
- Objects can be identified by a hash code
- The list is very big, so performance is an issue
- The idea is to compare an old list to a new list to see if any new hash codes have popped up.
You will want to store your objects in a dictionary:
var list = new Dictionary<string, CustomObject>();
When you add them, provide the hash as the key:
list.Add(customObject.Hash, customObject);
To scan for new ones:
var difference = new List<CustomObject>();
foreach (customObject o in newList)
{
if (oldList.ContainsKey(o.Hash)) difference.Add(o);
}
Log(String.Format("{0} new hashes found.", difference.Count));
By using the Dictionary you take advantage of the way the keys are stored in a hash table. Finding an item in a hash table is faster than just doing a scan & compare sort of thing. I believe this will be O(n*log(n)) instead of O(n^2).