Sorting algorithms/Quicksort: Difference between revisions

Content added Content deleted
m (Removed dependency on C# 9 init methods from properties.)
m (Minor datatype adjustment.)
Line 1,795: Line 1,795:
#region Properties
#region Properties
public Int32 InsertionLimit { get; }
public Int32 InsertionLimit { get; }
private T[] Samples { get; }
private Int32 Left { get; set; }
private Int32 Right { get; set; }
private Int32 LeftMedian { get; set; }
private Int32 RightMedian { get; set; }
#endregion
//
// The Tripartite conditional enables Bentley-McIlroy 3-way Partitioning.
// This performs additional compares to isolate islands of keys equal to
// the pivot value. Use unless key-equivalent classes are of small size.
//
#define Tripartite

namespace RosettaCode {
using System;
using System.Diagnostics;

public class QuickSort<T> where T : IComparable {
#region Constants
public const UInt32 INSERTION_LIMIT_DEFAULT = 12;
private const Int32 SAMPLES_MAX = 19;
#endregion

#region Properties
public UInt32 InsertionLimit { get; }
private T[] Samples { get; }
private T[] Samples { get; }
private Int32 Left { get; set; }
private Int32 Left { get; set; }
Line 1,803: Line 1,828:


#region Constructors
#region Constructors
public QuickSort(Int32 insertionLimit = INSERTION_LIMIT_DEFAULT) {
public QuickSort(UInt32 insertionLimit = INSERTION_LIMIT_DEFAULT) {
this.InsertionLimit = insertionLimit;
this.InsertionLimit = insertionLimit;
this.Samples = new T[SAMPLES_MAX];
this.Samples = new T[SAMPLES_MAX];