I've got a list which stores a number of objects. Each object has a property in the form of a variable.
I'd like to be able to check if any of the items in this list contain a certain property. Similar to the Dictionary's ContainsKey method. This data structure is to hold an extremely large amount of values, possibly even millions and I would thus like to use a data structure which can check the properties as fast as possible.
Would Dictionary be the fastest for this job, or are there faster data structures?
EDIT:
Here's a quick, small example of what I'd like to achieve:
Dictionary<string, Person> persons = new Dictionary<string, Person>(); //where string contains the Person's name
bool isPresent = persons.ContainsKey("Matt");
It sounds like you basically just need a HashSet<T>
containing all the property values - assuming you really just want to know whether it's contained or not.
For example:
var allNames = new HashSet<string>(people.Select(person => person.Name));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With