private static void MergeArrays(CList head)
        {
            var currentList = new CList();
            currentList.Next = head;
            head = currentList;
            for (int i = 0; i < NumberOfArrays * ArraysLength; i++)
            {
                currentList = head;
                var minElementList = head;
                while (currentList.Next != null)
                {
                    var k1 = currentList.Next.Data[currentList.Next.Point];
                    var k2 = minElementList.Next.Data[minElementList.Next.Point];
                    if (k1.Key < k2.Key)
                    {
                        minElementList = currentList;
                    }

                    currentList = currentList.Next;
                }

                Console.WriteLine(minElementList.Next.Data[minElementList.Next.Point].Key);
                if (minElementList.Next.Data.Length - 1 == minElementList.Next.Point)
                {
                    var q = minElementList.Next;
                    minElementList.Next = minElementList.Next.Next;
                }
                else
                {
                    minElementList.Next.Point++;
                }
            }
        }
Ejemplo n.º 2
0
        private static void MergeArrays(CList head)
        {
            var currentList = new CList();

            currentList.Next = head;
            head             = currentList;
            for (int i = 0; i < NumberOfArrays * ArraysLength; i++)
            {
                currentList = head;
                var minElementList = head;
                while (currentList.Next != null)
                {
                    var k1 = currentList.Next.Data[currentList.Next.Point];
                    var k2 = minElementList.Next.Data[minElementList.Next.Point];
                    if (k1.Key < k2.Key)
                    {
                        minElementList = currentList;
                    }

                    currentList = currentList.Next;
                }

                Console.WriteLine(minElementList.Next.Data[minElementList.Next.Point].Key);
                if (minElementList.Next.Data.Length - 1 == minElementList.Next.Point)
                {
                    minElementList.Next = minElementList.Next.Next;
                }
                else
                {
                    minElementList.Next.Point++;
                }
            }
        }
Ejemplo n.º 3
0
 static void PrintArrays(CList list)
 {
     while (list != null)
     {
         foreach (var element in list.Data)
         {
             Console.Write("{0} ", element.Key);
         }
         Console.WriteLine();
         list = list.Next;
     }
 }
        private static void PrintArrays(CList list)
        {
            while (list != null)
            {
                foreach (var element in list.Data)
                {
                    Console.Write("{0} ", element.Key);
                }

                Console.WriteLine();
                list = list.Next;
            }
        }
        static CList InitializeArray(int modul)
        {
            CList head = null;
            for (int i = 0; i < NumberOfArrays; i++)
            {
                var currentList = new CList();
                currentList.Length = NumberOfArrays;
                currentList.Point = 0;
                currentList.Data = new Element[ArraysLength];
                currentList.Data[0].Key = rand.Next() % modul;
                for (int j = 1; j < ArraysLength; j++)
                    currentList.Data[j].Key = currentList.Data[j - 1].Key + rand.Next() % modul;
                currentList.Next = head;
                head = currentList;
            }

            return head;
        }
Ejemplo n.º 6
0
        static CList InitializeArray(int modul)
        {
            CList head = null;

            for (int i = 0; i < NumberOfArrays; i++)
            {
                var currentList = new CList();
                currentList.Length      = NumberOfArrays;
                currentList.Point       = 0;
                currentList.Data        = new Element[ArraysLength];
                currentList.Data[0].Key = rand.Next() % modul;
                for (int j = 1; j < ArraysLength; j++)
                {
                    currentList.Data[j].Key = currentList.Data[j - 1].Key + rand.Next() % modul;
                }
                currentList.Next = head;
                head             = currentList;
            }

            return(head);
        }