static void Main(string[] args) { SplayTree ss = new SplayTree(); ss.Find(1); ss.Insert(1); ss.Find(1); ss.Insert(2); ss.Insert(1000000000); ss.Find(1000000000); ss.Delete(1000000000); ss.Find(1000000000); Console.WriteLine(); Console.Read(); }
private string Find(string arg, SplayTree tree) { long i = Convert(int.Parse(arg)); var temp = tree.Find(i); if (temp == null) { return("Not found"); } if (temp.Key == i) { return("Found"); } else { return("Not found"); } }
private string Find(string arg, SplayTree splayTree) { long i = Convert(int.Parse(arg)); var findResult = splayTree.Find(i); if (findResult != null) { if (findResult.Key == i) { return("Found"); } else { return("Not found"); } } return("Not found"); }
private string Sum(string arg, SplayTree splayTree) { var toks = arg.Split(); long l = Convert(long.Parse(toks[0])); long r = Convert(long.Parse(toks[1])); long sum = 0; var lowerBound = splayTree.Find(l); while (!(lowerBound.Key > r)) { sum += lowerBound.Key; lowerBound = splayTree.Next(lowerBound); } X = sum; return(sum.ToString()); }