//Actually it's too much code but maybe working. private PartitionRange Partition(T[] array, int lo, int hi) { var partition = new PartitionRange { Start = lo, End = lo }; var i = lo + 1; var j = hi; while (true) { if (i > j) { break; } while (Less(array[i], array[partition.Start])) { if (i > j) { break; } Swap(array, i, partition.Start); i++; partition.Start++; partition.End++; } while (array[j].CompareTo(array[partition.End]) > 0) { if (i > j) { break; } j--; } while (array[i].CompareTo(array[partition.Start]) == 0) { if (i > j) { break; } i++; partition.End++; } Swap(array, i, j); if (array[i].CompareTo(array[partition.End]) == 0) { if (i > partition.End + 1) { Swap(array, i, partition.End + 1); } partition.End++; } } return(partition); }
public ReplayCommand(PartitionRange partitionRange) => PartitionRange = partitionRange;