public int Debug(int depth, StringWriter sw, string path) { int sum = 0; for (int i = 0; i < depth; i++) { sw.Write(" "); } if (values == null) { sw.Write(path + " SpitAxis " + this.splittingAxis + " val " + this.split.ToString("R") + "\n"); sum += left.Debug(depth + 1, sw, path + "L"); sum += right.Debug(depth + 1, sw, path + "R"); } else { sw.Write(path + "{"); sum += values.Count; foreach (var v in values) { sw.Write(v + ", "); } sw.Write("}\n"); } return(sum); }
public string Debug() { StringWriter sw = new StringWriter(); sw.Write("KDTree:\n"); if (node == null) { sw.Write("null"); } else { int sum = node.Debug(0, sw, ""); sw.Write("\nTotal elements " + sum); } return(sw.ToString()); }