Friday, September 18, 2009

SortedSet <T> new collection type in .Net 4.0 beta 1

Hi folks,

This post based on my readings in .Net 4.0 beta 1, one of the new enhancements in .Net 4.0 is SortedSet<T> collection type, which implements red-black sorting algorithm with complexity O(log n) for the entire list.

Red-Black tree is an efficient sorting algorithm and using this collection will help alot from performance of sorting large sets in the run time.

C# code:

var mySet=new SortedSet <int>() {3,2,7,23,12,879,345,122,98};
foreach(int x in mySet)

// output: sorted list.

To read more about .Net 4.0 enhancements, kindly check below links:

Hope this helps.

Mostafa arafa


Ayman M El-Hattab said...

nice post man :)

Unknown said...

Thanks, and appreciate your tip for accept the blog < > operators.