Example #1
0
            public void GetRecordsFromVirtual(ListStruct source)//брать записи из источника в качестве списка
            {
                this.counter = source.counter;
                TabStud Record = source.ListRecord;//обьявили и присвоили запись шоб ходить по списку не изменяя головы

                this.Records = new TabStud[source.counter];
                for (int i = 0; i < source.counter - 1; i++)
                {

                    this.Records[i] = Record;
                    Record = Record.Next;
                }
                this.Records[source.counter - 1] = Record;
            }
Example #2
0
            public void SelectSort()
            {
                int i;
                for (i = 0; i < this.counter; i++)
                {

                    int minIndex = this.GetMinIndex(i);
                    TabStud tmp = this.Records[minIndex];
                    this.Records[minIndex] = this.Records[i];
                    this.Records[i] = tmp;

                }

            }
Example #3
0
            public TabStud[] mergeSort(TabStud[] massive)
            {
                if (massive.Length == 1)
                    return massive;
                Int32 mid_point = massive.Length / 2;
                TabStud[] M1 = new TabStud[mid_point];
                for (int i = 0; i < mid_point; i++)
                    M1[i] = massive[i];
                TabStud[] M2 = new TabStud[massive.Length - mid_point];
                for (int i = 0; i < massive.Length - mid_point; i++)
                    M2[i] = massive[i + mid_point];


                return Merge(mergeSort(M1), mergeSort(M2));

            }
Example #4
0
 public ListStruct SetRecordsToVirtual()// если  в последствии используемый алгоритм изменит данные, то 
 {//выполниим эту функцию которая вернет в место назначения список..
  //ток через ретурнс ибо свойства нельзя передавать как пареметр через реф!!
     var dest = new ListStruct(DGV);
     // /*this.Records[0].Next =*/ this.Records[this.counter - 1].Next = null;
     TabStud Record = this.Records[0];//записали какбэ голову
     dest.ListRecord = Record;//и отдали в дест
     dest.LastOf = this.Records[this.counter - 1];
     dest.LastOf.Next = null;
     dest.counter = this.counter;
     for (int i = 0; i < (this.counter - 2); i++)
     {
         this.Records[i].Next = this.Records[i + 1];
         Record = this.Records[i];
         Record = Record.Next;
     }
     this.Records[this.counter - 2].Next = this.Records[this.counter - 1];
     return dest;
 }
Example #5
0
 public TabStud[] Merge(TabStud[] mass1, TabStud[] mass2)
 {
     Int32 a = 0, b = 0;
     TabStud[] merged = new TabStud[mass1.Length + mass2.Length];
     for (Int32 i = 0; i < mass1.Length + mass2.Length; i++)
     {
         if (b < mass2.Length && a < mass1.Length)
             if (mass1[a].Key.CompareTo(mass2[b].Key) == 1 && b < mass2.Length)
                 merged[i] = mass2[b++];
             else
                 merged[i] = mass1[a++];
         else
             if (b < mass2.Length)
             merged[i] = mass2[b++];
         else
             merged[i] = mass1[a++];
     }
     return merged;
 }
Example #6
0
            public void PSort()
            {
                DateTime start = DateTime.Now;


                TabStud[] FM = new TabStud[this.Records.LongLength];
                int[] c = new int[this.Records.LongLength];
                for (Int64 i = 0; i < this.Records.LongLength; i++) c[i] = 0;

                for (Int64 i = 0; i < this.Records.LongLength - 1; i++)
                {
                    for (Int64 j = i + 1; j < this.Records.LongLength; j++)
                    {
                        if (this.Records[i].Key.CompareTo(this.Records[j].Key) == 1)
                            c[i]++;
                        else
                            c[j]++;
                    }
                }
                for (Int64 i = 0; i < this.Records.LongLength; i++)
                    FM[c[i]] = this.Records[i];
                this.Records = FM;
            }
Example #7
0
            public void BulbSort()
            {

                for (Int64 i = 0; i < Records.Length; i++)
                {
                    bool f = true;
                    for (Int64 j = 0; j < Records.Length; j++)
                    {

                        if (Records[i].Key.CompareTo(Records[j].Key) == -1) { TabStud tmp = Records[i]; Records[i] = Records[j]; Records[j] = tmp; f = false; }
                    }

                    if (f) break;
                }
            }