I am looking for the fastest way to find all the rows in a collection, starting with a character set. I can use a sorted collection for this, however I cannot find a convenient way to do this in .net. Mostly I need to find low and high indexes in a collection that matches the criteria.
BinarySearch in the <T> list does not guarantee that the returned index refers to the first element, so you will need to iterate up and down to find all matching rows that are not fast if you have a large list.
There are also Linq methods (with parallel ones), but I'm not sure which data structure will provide the best results.
List example, ~ 10M entries:
aaaaaaaaaaaaaaabb
aaaaaaaaaaaaaaba
aaaaaaaaaaaaabc
...
zzzzzzzzzzzzzxx
zzzzzzzzzzzzzyzzz
zzzzzzzzzzzzzzzzzza
Search lines starting with: skk ...
Result: write indices from x to y.
UPDATE: .