Beispiel #1
0
 public void add(int k,Move m)
 {
     if (key == k) Moves.Add(m);
     else
     {
         if (k < key)
         {
             if (left != null) left.add(k,m);
             else left=new MovesTree(k,m);
         }
         else
         {
             if (right != null) right.add(k,m);
             else right= new MovesTree(k,m);
         }
     }
 }
Beispiel #2
0
 public void add(int k)
 {
     if (key == k) return;
     else
     {
         if (k < key)
         {
             if (left != null) left.add(k);
             else left = new MovesTree(k);
         }
         else
         {
             if (right != null) right.add(k);
             else right = new MovesTree(k);
         }
     }
 }
Beispiel #3
0
 public WaysFinder(string fileName)
 {
     MovesArr = new Move[100000];
     StreamReader sr = new StreamReader(fileName);
     while (sr.EndOfStream == false)
     {
         MovesArr[MovesCount] = new Move(sr.ReadLine());
         MovesCount++;
     }
     int max=0,i;
     for (i = 0; i < MovesCount; i++) if (MovesArr[i].from > max) max = MovesArr[i].from;
     tree = new MovesTree(max);
     tree.add(max/2);
     tree.add(max / 4);
     tree.add(max*3/4);
     for (i = 0; i < MovesCount; i++) tree.add(MovesArr[i].from, MovesArr[i]);
     start = MovesArr[0].from;
     MovesArr=null;
 }