public static void Sort <T>( this ArrayIterator <T> first, ArrayIterator <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 ArrayIterator <T> first, ArrayIterator <T> nth, ArrayIterator <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 ArrayIterator <T> first, ArrayIterator <T> middle, ArrayIterator <T> last, Func <T, T, bool> comp ) { // TODO find a faster algorithm that doesn't create any garbage first.Sort(last, comp); }