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); } } }
public MovesTree(int newKey, Move newMove) { key = newKey; Moves.Add(newMove); }
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; }