In memory you have several options.
Most options will have O (n). In this case, dictionary search queries can approach O (1).
One option is to store your customers in several dictionaries, each with a key set to name, identifier and age. If you use the same object references in dictionaries, you can do any O (1) search without a huge amount of overhead.
Of course, this becomes less practical as the number of your criteria increases, but with 3, this is not so bad.
If you need more flexibility, then a database is an option. Many databases have the ability to work as a fully integrated database, including SQLite, which allows arbitrary queries much better than O (n).
Reed copsey
source share