Ejemplo n.º 1
0
        public static long InsertionTime(float[] array, TimeType type) => InsertionAlgorithm.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 InsertionTimePrint(float[] array, TimeType type)
        {
            if (type == TimeType.Both)
            {
                return(string.Format("Insertion Sorting Duration: {0} Miliseconds / {1} Ticks.", InsertionAlgorithm.Time(array, TimeType.Miliseconds), InsertionAlgorithm.Time(array, TimeType.Ticks))); //returns preprepared messageof time
            }
            return(string.Format("Insertion Sorting Duration: {0} {1}", InsertionAlgorithm.Time(array, type), type == TimeType.Ticks ? "Ticks." : "Miliseconds."));                                      //returns preprepared message of time
        }
Ejemplo n.º 2
0
        public void InsertionTest()
        {
            Initialize();
            var insertion = new InsertionAlgorithm(Items.ToArray());

            insertion.Sort(cancellationTokenSource.Token);

            var collection = insertion.GetCollection();

            for (int i = 0; i < insertion.CollectionSize; i++)
            {
                Assert.AreEqual(Sorted[i], collection[i]);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns duration of algorithm calculations in ticks.
 /// </summary>
 /// <param name="array">Float array to sort.</param>
 /// <param name="type">Type of returned duration.</param>
 public static long InsertionTime(float[] array, TimeType type) => InsertionAlgorithm.Time(array, type); //returns time
Ejemplo n.º 4
0
 /// <summary>
 /// Insertion sort on double values.
 /// </summary>
 /// <param name="array">Double array to sort.</param>
 public static void Insertion(double[] array) => InsertionAlgorithm.Insertion(array);
Ejemplo n.º 5
0
 /// <summary>
 /// Insertion sort on float values.
 /// </summary>
 /// <param name="array">Float array to sort.</param>
 public static void Insertion(float[] array) => InsertionAlgorithm.Insertion(array);
Ejemplo n.º 6
0
 /// <summary>
 /// Insertion sort on long values.
 /// </summary>
 /// <param name="array">Long array to sort.</param>
 public static void Insertion(long[] array) => InsertionAlgorithm.Insertion(array);