static void Main(string[] args) { Console.WriteLine("Hello World!"); var watch = new Stopwatch(); var array1 = GenerateRandomArray(100000); var array2 = new int [array1.Length]; Array.Copy(array1, array2, array1.Length); PartitionDelegate part = Partition; watch.Start(); QuickSort(array1, 0, array1.Length, part); watch.Stop(); Console.WriteLine(watch.Elapsed); //PrintArray(array1); PartitionDelegate randomPart = PartitionRandom; watch.Start(); QuickSort(array2, 0, array2.Length, randomPart); watch.Stop(); Console.WriteLine(watch.Elapsed); //PrintArray(array2); }
public QuickSort(IList <IComparable> list) { _Random = new Random(); _PartitionFunction = PartitionRandom; _SortedList = list; chart = new List <QuickSortChart>(); }
private bool SetPartition(uint parts, DatabaseEntry[] partKeys, PartitionDelegate partFunc) { partitionIsSet = true; nparts = parts; partitionKeys = partKeys; partitionFunc = partFunc; if (nparts < 2) partitionIsSet = false; else if (partitionKeys == null && partitionFunc == null) partitionIsSet = false; return partitionIsSet; }
public Quicksort(bool randomPartition) { if (randomPartition) { _random = new Random(); _partitionFunction = PartitionRandom; } else { _partitionFunction = PartitionRight; } }
static void QuickSort(int[] array, int start, int end, PartitionDelegate partition) { if (start < end) { if (end - start < 10) { InsertionSort(array); } else { var pivot = partition(array, start, end); QuickSort(array, start, pivot, partition); QuickSort(array, pivot + 1, end, partition); } } }
private void BtPartitionClick(object sender, EventArgs e) { var form = new Dialog.NodeActionForm("partition"); var result = form.ShowDialog(); if (result == DialogResult.OK) { int server_count = Int32.Parse(form.item1); String[] args = new String[2 + server_count]; args[0] = form.item1; args[1] = form.item2; // Send ids as separate list item to be processed the same way as if it were a script String ids = form.item3; String[] ids_list = ids.Split(" "); for (int i = 0; i < server_count; i++) { args[i + 2] = ids_list[i]; } PartitionDelegate del = new PartitionDelegate(Partition); var workTask = Task.Run(() => del.Invoke(args)); } }
/// <summary> /// Enable database partitioning using the specified number of /// partitions and partition function. /// Return true if the specified number of partitions are successfully /// enabled; otherwise return false. /// <param name="parts">The number of partitions to create</param> /// <param name="partFunc">The name of partitioning function</param> /// </summary> public bool SetPartitionByCallback( uint parts, PartitionDelegate partFunc) { return(SetPartition(parts, null, partFunc)); }
/// <summary> /// Enable database partitioning using the specified number of /// partitions and partition function. /// Return true if the specified number of partitions are successfully /// enabled; otherwise return false. /// <param name="parts">The number of partitions to create</param> /// <param name="partFunc">The name of partitioning function</param> /// </summary> public bool SetPartitionByCallback( uint parts, PartitionDelegate partFunc) { return (SetPartition(parts, null, partFunc)); }