Common data collection algorithms in C #

Is there a library of common data collection algorithms for .NET? I would like 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 itemsnot List<T>, otherwise I could just use the List<T>.Sortand methods List<T>.BinarySearch.

Of course, I can implement them myself, I just do not want to reinvent the wheel.

I would also like the implementation to be effective.

PS

Please do not tell which collections to use. I perfectly understand the abilities Arrayor List<T>. I need a library of algorithms to work with any collection based on IList<T>.

EDIT: Found what I needed - see my own answer.

+3
9

PowerCollections Wintellect.

Algorithms , BinarySearch<T> SortInPlace<T>, IList<T>.

+1

,.NET BinarySearch, IList<T>.

Linq , . IList<T> SO.

, Linq, , .

+2

:

. .

sort() IList . :

int[] sortingArray = { 12, 5, 2, 7, 66 };
IComparer<int> comparer = new SortComparer();
sortingArray.Sort(SortStrategy.HeapSort, comparer);

, .

+1

Array (Sort IndexOf).

:

IList<string> foo = new List<string>();
foo.Add("hi");
foo.Add("bye");
string[] foo_temp = new string[foo.Count];
foo.CopyTo(foo_temp, 0);
Array.Sort<String>(foo_temp);
foo = new List<string>(foo_temp);
0

LINQ OrderBy.

0

IndexOfKey SortedList < > .

0

, . , , , , . ? . Linq .NET , .

0

. Reflector, List.Sort Array.BinarySearch IList<T>.

, (, # 2), :

Algorithms<T>.Sort(items);

Sort ( ) Algorithms, , :

Algorithms.Sort(items);
0

Source: https://habr.com/ru/post/1713230/


All Articles