.Net 4.0 New Feature - SortedSet
int[] array = new int[setData1.Count];
setData1.CopyTo(array);
foreach (var value in array)
setData1.Add(value);
System.Console.WriteLine("setData1");
System.Console.WriteLine(string.Join(",", setData1));
System.Console.WriteLine("setData2");
System.Console.WriteLine(string.Join(",", setData2));
System.Console.WriteLine("setData1 IsSubsetOf setData2");
System.Console.WriteLine(string.Join(",", setData1.IsSubsetOf(setData2)));
System.Console.WriteLine("setData1 Overlaps setData2");
System.Console.WriteLine(string.Join(",", setData1.Overlaps(setData2)));
System.Console.WriteLine("setData1 UnionWith setData2");
var setUnion = new SortedSet<int>(setData1);
setUnion.UnionWith(setData2);
System.Console.WriteLine(string.Join(",", setUnion));
System.Console.WriteLine("(setData1 UnionWith setData2) Reverse");
System.Console.WriteLine(string.Join(",", setUnion.Reverse()));
System.Console.WriteLine("(setData1 UnionWith setData2) Min");
System.Console.WriteLine(string.Join(",", setUnion.Min));
System.Console.WriteLine("(setData1 UnionWith setData2) Max");
System.Console.WriteLine(string.Join(",", setUnion.Max));
System.Console.WriteLine("(setData1 UnionWith setData2) GetViewBetween({0},{1})", (setUnion.Min + setUnion.Max) / 2, setUnion.Max);
System.Console.WriteLine(string.Join(",", setUnion.GetViewBetween((setUnion.Min + setUnion.Max) / 2, setUnion.Max)));
System.Console.WriteLine("(setData1 UnionWith setData2) IsSupersetOf setData1");
System.Console.WriteLine(string.Join(",", setUnion.IsSupersetOf(setData1)));
System.Console.WriteLine("(setData1 UnionWith setData2) IsSupersetOf setData2");
System.Console.WriteLine(string.Join(",", setUnion.IsSupersetOf(setData2)));
System.Console.WriteLine("setData1 IsSubsetOf (setData1 UnionWith setData2)");
System.Console.WriteLine(string.Join(",", setData1.IsSubsetOf(setUnion)));
System.Console.WriteLine("setData2 IsSubsetOf (setData1 UnionWith setData2)");
System.Console.WriteLine(string.Join(",", setData2.IsSubsetOf(setUnion)));
System.Console.WriteLine("(setData1 UnionWith setData2) IntersectWith setData2");
var setIntersect = new SortedSet<int>(setUnion);
setIntersect.IntersectWith(setData2);
System.Console.WriteLine(string.Join(",", setIntersect));
System.Console.WriteLine("(setData1 UnionWith setData2) ExceptWith setData2");
var setExcept = new SortedSet<int>(setUnion);
setExcept.ExceptWith(setData2);
System.Console.WriteLine(string.Join(",", setExcept));
System.Console.WriteLine("(setData1 UnionWith setData2) RemoveWhere((value) => (value % 2) == 0)");
var setRemoveWhere = new SortedSet<int>(setUnion);
setRemoveWhere.RemoveWhere((value) => (value % 2) == 0);
System.Console.WriteLine(string.Join(",", setRemoveWhere));
}
}
}