суббота, 17 февраля 2018 г.
Ok, this one is a long story. Frequently we need to search in a collection of objects. Typical solution is to store the collection not as List<Person> (because searching by Person.Name in a List<Person> will be O(N) operation), but as a Dictionary<string, Person> where key represents the name. Searching in this collection will be a O(log(N)) operation what is much better. The problem here is that if we want to search by name and last name we are forced to maintain 2 different Dictionary<string, Person>, one for the Name and second for the Last Name. But now there is something we can do about that.