Beispiel #1
0
        public static void Swap(MyDict md1, MyDict md2)
        {
            MyDict tmp = new MyDict(md1.Key, md1.Value);

            Copy(md1, md2);
            Copy(md2, tmp);
        }
Beispiel #2
0
            public void OpenMass(string name)
            {
                StreamReader reader = File.OpenText(name);
                string line;
                string[] fields;
                if (!reader.EndOfStream)
                {
                    counter = Convert.ToInt32(reader.ReadLine());
                    MyDict[] TmpMass = new MyDict[counter];

                    for (int i = 0; i < counter; i++)
                    {

                        line = reader.ReadLine();
                        line = line.Trim();
                        fields = line.Split('_');//шайтанама над строками . разбиваем по разделителю _
                        TmpMass[i] = new MyDict();
                        TmpMass[i].Key = fields[0];
                        TmpMass[i].Txtinfo = fields[1];// прописали поля
                    }
                    Records = TmpMass;
                    TmpMass = null;
                }
                reader.Dispose();
            }
Beispiel #3
0
 public void InsertionSort(ref MyDict[] Dict, out int swapCount)
 {
     swapCount = 0;
     for (int i = 1; i < Dict.Length; i++)
     {
         int    j;
         MyDict temp = new MyDict();
         for (j = i - 1; j >= 0; j--)
         {
             if (Dict[j].Key.CompareTo(temp.Key) < 0)
             {
                 break;
             }
             swapCount++;
             Dict[j + 1] = Dict[j];
         }
         Dict[j + 1] = temp;
     }
 }
Beispiel #4
0
 public static void ReadFile(ref MyDict[] myDict, string filename)
 {
     try
     {
         int          i    = 0;
         StreamReader file = new StreamReader(filename);
         string       line;
         char[]       separators = { ';', ':' };
         string[]     buf;
         while ((line = file.ReadLine()) != null)
         {
             buf = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
             try
             {
                 if (buf.Length != 2)
                 {
                     throw new Exception("Error, in line more or less than 2 separators");
                 }
             }
             catch (Exception e)
             {
                 MessageBox.Show(e.Message);
             }
             i++;
             Array.Resize <MyDict>(ref myDict, i);
             myDict[i - 1] = new MyDict(buf[0], buf[1]);
         }
     }
     catch (FileNotFoundException e)
     {
         MessageBox.Show(e.Message + "Check correctness name file");
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Beispiel #5
0
 public bool Equals(MyDict md)
 {
     return(this.ToString() == md.ToString());
 }
Beispiel #6
0
 public static void Copy(MyDict to, MyDict from)
 {
     to = new MyDict(from.Key, from.Value);
 }