public void TestBubbleSort_EmptyJaggedArrayFirstItemDesc_ArgumentException() { var jaggedArray = new int[0][]; int parameter(int[] arr) => arr[0]; Assert.Throws <ArgumentException>(() => BubbleAlgorithm.BubbleSort(jaggedArray, parameter)); }
public static long BubbleTime(float[] array, TimeType type) => BubbleAlgorithm.Time(array, type); //returns time /// <summary> /// Returns prepared message of duration in ticks. /// </summary> /// <param name="array">Float array to sort.</param> /// <param name="type">Type of returned duration.</param> public static string BubbleTimePrint(float[] array, TimeType type) { if (type == TimeType.Both) { return(string.Format("Bubble Sorting Duration: {0} Miliseconds / {1} Ticks.", BubbleAlgorithm.Time(array, TimeType.Miliseconds), BubbleAlgorithm.Time(array, TimeType.Ticks))); //returns preprepared messageof time } return(string.Format("Bubble Sorting Duration: {0} {1}", BubbleAlgorithm.Time(array, type), type == TimeType.Ticks ? "Ticks." : "Miliseconds.")); //returns preprepared message of time }
public void TestBubbleSort_JaggedArrayByNull_ArgumentNullException() { var jaggedArray = new int[][] { new int[] { 1 }, new int[] { 2, 5, 2, 2, 1 }, new int[] { 3, 1, 2 }, new int[] { 4, 1, 4, 3 } }; Assert.Throws <ArgumentNullException>(() => BubbleAlgorithm.BubbleSort(jaggedArray, null)); }
public void TestBubbleSort_JaggedArrayWithNullByFirstItemDesc_ArgumentNullException() { var jaggedArray = new int[][] { new int[] { 1 }, new int[] { 2, 5, 2, 2, 1 }, null, new int[] { 4, 1, 4, 3 } }; int parameter(int[] arr) => arr[0]; Assert.Throws <ArgumentNullException>(() => BubbleAlgorithm.BubbleSort(jaggedArray, parameter)); }
public void BubbleTest() { Initialize(); var bubble = new BubbleAlgorithm(Items.ToArray()); bubble.Sort(cancellationTokenSource.Token); var collection = bubble.GetCollection(); for (int i = 0; i < bubble.CollectionSize; i++) { Assert.AreEqual(Sorted[i], collection[i]); } }
public void TestBubbleSortByMax_JaggedArray_SortedArray() { var jaggedArray = new int[][] { new int[] { 1, 2, 3, 4, 5, 6, 7 }, new int[] { 1, 2, 3, 4 }, new int[] { 1, 2, 3, 4, 5 }, new int[] { 1, 2 } }; var expected = new int[][] { new int[] { 1, 2 }, new int[] { 1, 2, 3, 4 }, new int[] { 1, 2, 3, 4, 5 }, new int[] { 1, 2, 3, 4, 5, 6, 7 } }; BubbleAlgorithm.BubbleSortByMax(jaggedArray); Assert.AreEqual(expected, jaggedArray); }
public void TestBubbleSortByMin_JaggedArrayDesc_SortedArray() { var jaggedArray = new int[][] { new int[] { 4, 5, 6, 7 }, new int[] { 2, 3, 4 }, new int[] { 3, 4, 5 }, new int[] { 1, 2 } }; var expected = new int[][] { new int[] { 4, 5, 6, 7 }, new int[] { 3, 4, 5 }, new int[] { 2, 3, 4 }, new int[] { 1, 2 } }; BubbleAlgorithm.BubbleSortByMin(jaggedArray, true); Assert.AreEqual(expected, jaggedArray); }
public void TestBubbleSort_JaggedArrayByFirstItemDesc_SortedArray() { var jaggedArray = new int[][] { new int[] { 1 }, new int[] { 2, 5, 2, 2, 1 }, new int[] { 3, 1, 2 }, new int[] { 4, 1, 4, 3 } }; var expected = new int[][] { new int[] { 4, 1, 4, 3 }, new int[] { 3, 1, 2 }, new int[] { 2, 5, 2, 2, 1 }, new int[] { 1 }, }; int parameter(int[] arr) => arr[0]; BubbleAlgorithm.BubbleSort(jaggedArray, parameter, true); Assert.AreEqual(expected, jaggedArray); }
public BubbleSeries(object configuration) { Model = new BubbleAlgorithm(this); Configuration = configuration; InitializeDefuaults(); }
public BubbleSeries() { Model = new BubbleAlgorithm(this); InitializeDefuaults(); }
public void TestBubbleSort_NullByNull_ArgumentNullException() { Assert.Throws <ArgumentNullException>(() => BubbleAlgorithm.BubbleSort(null, null)); }
public void TestBubbleSort_NullByFirstItemDesc_ArgumentNullException() { int parameter(int[] arr) => arr[0]; Assert.Throws <ArgumentNullException>(() => BubbleAlgorithm.BubbleSort(null, parameter)); }
/// <summary> /// Returns duration of algorithm calculations in ticks. /// </summary> /// <param name="array">Flaot array to sort.</param> /// <param name="type">Type of returned duration.</param> public static long BubbleTime(float[] array, TimeType type) => BubbleAlgorithm.Time(array, type); //returns time
/// <summary> /// Sorting an double array with using bubble algorithm. /// </summary> /// <param name="array">Double array to sort.</param> public static void Bubble(double[] array) => BubbleAlgorithm.Sort(array);
/// <summary> /// Sorting an float array with using bubble algorithm. /// </summary> /// <param name="array">Float array to sort.</param> public static void Bubble(float[] array) => BubbleAlgorithm.Sort(array);