Is there a library of generic collection algorithms for .NET? I would like to be able to write something like this:
IList<T> items = GetItemsFromSomeWhere();
Algorithms<T>.Sort(items);
//
// ....
//
T item = GetItemSomwHow();
int i = Algorithms<T>.IndexOf(items, item);
Note, that items is not List<T>, otherwise I could simply use the List<T>.Sort and List<T>.BinarySearch methods.
Of course, I can implement them myself, I just do not want to reinvent the wheel.
I would also like the implementation to be efficient.
P.S.
Please, do not advise on which collections to use. I am perfectly aware of the Array or List<T> abilities. What I need is a library of algorithms to work on any IList<T> based collection.
EDIT:
Found what I needed – see my own answer.
After doing some research I have found the PowerCollections library from
Wintellect.Aside from supplying various collections it provides a static
Algorithmsclass with quite a few algorithms, includingBinarySearch<T>andSortInPlace<T>, which expect anyIList<T>.