Example #1
0
 static void AddNrandoms(Queue1 q, int count)
 {
     for (int i = 0; i < count; i++)
     {
         q.AddLast(rnd.Next(1, 100));
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            foreach (int N in new int[] { 3000, 60000, 120000, 240000, 350000, 450000, 700000, 3840000 })
            {
                N_op = 0;
                Queue1 qu = new Queue1(N);
                AddNrandoms(qu, N);
                DateTime before = DateTime.Now;
                Queue1.StartQSort(ref qu);
                double time = (DateTime.Now - before).TotalMilliseconds;

                Console.WriteLine($"N: {N}    TotalMilliseconds: {time}    N_ops:{N_op}");
            }
        }
Example #3
0
 public void Set(int index, int item)               // Queue 0 1 2 3 4 5 6
 {                                                  // Set(2,9) ->
     if (size != storage.Length)                    // Queue 1 2 3 4 9 5 6
     {
         size++;
         head_pos_cur--;
         Queue1 temporary_q = new Queue1(Length());
         for (int i = 0; i < index; i++)
         {
             temporary_q.AddLast(this.GetFirst());
         }
         temporary_q.AddLast(item);
         for (int i = 1; i < Length() - index; i++)
         {
             temporary_q.AddLast(this.GetFirst());
         }
         for (int i = 0; i < Length(); i++)
         {
             this.AddLast(temporary_q.GetFirst());
         }
         temporary_q.Clear();
     }
 }
Example #4
0
        public int Get(int index)
        {
            Queue1 temporary_q = new Queue1(Length() - 1);

            for (int i = 0; i < index; i++)
            {
                temporary_q.AddLast(this.GetFirst());
            }
            int toReturn = this.GetFirst();

            for (int i = 1; i < Length() - index; i++)
            {
                temporary_q.AddLast(this.GetFirst());
            }
            for (int i = 0; i < Length(); i++)
            {
                this.AddLast(temporary_q.GetFirst());
            }
            temporary_q.Clear();
            size--;
            head_pos_cur++;
            return(toReturn);
        }
Example #5
0
 // Sorting block
 static internal void StartQSort(ref Queue1 ex) // Метод для запуска сортировки
 {
     Program.N_op += 1;
     quickSort(ex.ToArray(), 0, ex.Length() - 1);
 }