public static void Sort <T>( this ListIterator <T> first, ListIterator <T> last, Func <T, T, bool> comp ) { // Quicksort if (first.IsEqual(last)) { return; } var sep = first; for (var i = first.GetNext(); i.NotEqual(last); i = i.GetNext()) { if (comp(i.GetCurrent(), first.GetCurrent())) { sep = sep.GetNext(); sep.Swap(i); } } first.Swap(sep); first.Sort(sep, comp); sep.GetNext().Sort(last, comp); }
public static void NthElement <T>( this ListIterator <T> first, ListIterator <T> nth, ListIterator <T> last, Func <T, T, bool> comp ) { // TODO find a faster algorithm that doesn't create any garbage first.Sort(last, comp); }
public static void PartialSort <T>( this ListIterator <T> first, ListIterator <T> middle, ListIterator <T> last, Func <T, T, bool> comp ) { // TODO find a faster algorithm that doesn't create any garbage first.Sort(last, comp); }