static void Main(string[] args) { #region 数组 //ArrayList num = new ArrayList(); //num.Add("a"); //num.Add("b"); //num.Add("c"); //foreach(var item in num) //{ // Console.WriteLine(num.IndexOf(item) + ":" + item); //} //Console.WriteLine(num.Capacity); //Console.WriteLine(num.Count); //num.Add("d"); //num.Add("e"); //num.Add("f"); //foreach (var item in num) //{ // Console.WriteLine(num.IndexOf(item) + ":" + item); //} //Console.WriteLine(num.Capacity); //Console.WriteLine(num.Count); //num.Remove("f"); //num.Remove("e"); //num.Remove("d"); //Console.WriteLine(num.Capacity); //Console.WriteLine(num.Count); #endregion #region 双向链表 //LinkedList<string> linked = new LinkedList<string>(); //linked.AddFirst("a"); //linked.AddFirst("b"); //linked.AddFirst("c"); //linked.AddLast("d"); //foreach(var item in linked) //{ // Console.WriteLine(item); //} //DoubleLink<int> dlink = new DoubleLink<int>();// 创建双向链表 //Console.WriteLine("将 20 插入到表头之后"); //dlink.Append(0, 10); //dlink.ShowAll(); //Console.WriteLine("将 40 插入到表头之后"); //dlink.Append(1, 30); //dlink.ShowAll(); //Console.WriteLine("将 10 插入到表头之前"); //dlink.Insert(0, 40); //dlink.ShowAll(); //Console.WriteLine("将 30 插入到第一个位置之前"); //dlink.Insert(1, 20); //dlink.ShowAll(); //dlink.Insert(2, 25); //dlink.ShowAll(); //Console.WriteLine("展示第一个:" + dlink.GetFirst()); //Console.WriteLine("删除第一个"); //dlink.DelFirst(); //Console.WriteLine("展示第一个:" + dlink.GetFirst()); //Console.WriteLine("展示最后一个:" + dlink.GetLast()); //Console.WriteLine("删除最后一个"); //dlink.DelLast(); //Console.WriteLine("展示最后一个:" + dlink.GetLast()); //dlink.ShowAll(); //Console.ReadKey(); #endregion #region 二叉查询树 BinaryTree binaryTree = new BinaryTree(); //for (var i = 0; i < 5; i++) //{ // Random random = new Random(); // int num = random.Next(0, 100); // binaryTree.Add(num); //} binaryTree.Add(15); binaryTree.Add(20); binaryTree.Add(10); binaryTree.Add(5); binaryTree.Add(18); binaryTree.Add(6); binaryTree.Add(19); binaryTree.Add(17); binaryTree.Add(4); binaryTree.Add(12); //binaryTree.Add(11); binaryTree.Add(13); binaryTree.Preorder(); Tree tree = binaryTree.Search(4); //if (tree != null) //{ // Console.WriteLine(tree.Data); //} //binaryTree.Delete(4); //binaryTree.Delete(12); binaryTree.Delete(20); #endregion #region Hash一致性 //int Replicas = 100; //KetamaNodeLocator.AddNode("127.0.0.1:6379", Replicas); //KetamaNodeLocator.AddNode("127.0.0.1:6380", Replicas); //KetamaNodeLocator.AddNode("127.0.0.1:6381", Replicas); //List<string> nodes = new List<string>(); //for (int i = 0; i < 100; i++) //{ // nodes.Add(KetamaNodeLocator.GetTargetNode(i + "test" + (char)i)); //} //var counts = nodes.GroupBy(n => n, n => n.Count()).ToList(); //counts.ForEach(index => Console.WriteLine(index.Key + "-" + index.Count())); //Console.ReadLine(); #endregion //Cat.sid = 100; //Cat mimi = new Cat("mimi"); //Cat pipi = new Cat("pipi"); //bool bol = true; //Int32 i = new Int32(); //int j = 1; //int k = bol ? i : j; //Console.WriteLine(k); Console.ReadLine(); }