static void Main() { // keep this function call here var a = Circle.create(1.0); var b = Triangle.create(new double[] { 2.0, 2.0, 2.0 }); var c = Triangle.create(new double[] { 2.0, 2.0, 3.0 }); var d = Triangle.create(new double[] { 3.0, 4.0, 5.0 }); var e = Quadrilateral.create(new double[] { 3.0, 3.0 }); var f = Quadrilateral.create(new double[] { 3.0, 5.0 }); var g = Triangle.create(new double[] { 1.0, 2.0, 1.0 }); // list var list = new SharpList(); list.addSharp(a); list.addSharp(b); list.addSharp(c); list.addSharp(d); list.addSharp(e); list.addSharp(f); list.addSharp(g); // sort Console.WriteLine("-- Sort By Perimeter ASC ---"); list.SortByPerimeter(); foreach (var sharp in list) { sharp.PrintInfo(); } Console.WriteLine("-- Sort By Perimeter DESC ---"); list.SortByPerimeter(desc: true); foreach (var sharp in list) { sharp.PrintInfo(); } Console.WriteLine("-- Sort By SurfaceArea ASC ---"); list.SortBySurfaceArea(); foreach (var sharp in list) { sharp.PrintInfo(); } Console.WriteLine("-- Sort By SurfaceArea DESC ---"); list.SortBySurfaceArea(desc: true); foreach (var sharp in list) { sharp.PrintInfo(); } // write to json file list.saveToFile(); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); //Console.WriteLine( System.Globalization.CultureInfo.CurrentCulture.ToString() ); //NetSimplifyClient AccountSimplifyClient = new NetSimplifyClient( "127.0.0.1", 23456 ); //OperateResult<NetHandle,string> read = AccountSimplifyClient.ReadCustomerFromServer( 1, "" ); //if (read.IsSuccess) //{ // Console.WriteLine( "Handle:" + read.Content1 ); // Console.WriteLine( read.Content2 ); //} //else //{ // Console.WriteLine( "失败:" + read.Message ); //} //RedisSubscribe subscribe = new RedisSubscribe( "127.0.0.1", 6379, new string[] { "WareHouse:HuiBo" } ); //subscribe.CreatePush( ( m, n ) => //{ // Console.WriteLine( DateTime.Now.ToString() + " Key: " + m ); // Console.WriteLine( n ); //} ); //RedisClient redisClient = new RedisClient( "47.92.5.140", 6379, "" ); //redisClient.SetPersistentConnection( ); //MelsecMcNet melsecMc = new MelsecMcNet( "192.168.8.12", 6001 ); //melsecMc.SetPersistentConnection( ); //while (true) //{ // System.Threading.Thread.Sleep( 300 ); // OperateResult<int> read = melsecMc.ReadInt32( "D100" ); // if (!read.IsSuccess) { // Console.WriteLine( DateTime.Now.ToString( ) + " PLC Read Failed: " + read.Message ); // continue; // }; // OperateResult write = redisClient.WriteKey( "Test", read.Content.ToString( ) ); // if (write.IsSuccess) // { // Console.WriteLine( DateTime.Now.ToString( ) + " Write Success!" ); // } // else // { // Console.WriteLine( DateTime.Now.ToString( ) + " Write Failed : " + write.Message ); // } //} SimpleHybirdLock hybirdLock = new SimpleHybirdLock( ); int[] buffer = new int[1000]; DateTime start = DateTime.Now; for (int i = 0; i < 100000; i++) { hybirdLock.Enter( ); for (int j = 0; j < buffer.Length - 1; j++) { buffer[j] = buffer[j + 1]; } buffer[999] = i; hybirdLock.Leave( ); } Console.WriteLine((DateTime.Now - start).TotalMilliseconds); start = DateTime.Now; for (int i = 0; i < 100000; i++) { hybirdLock.Enter( ); int[] newbuffer = new int[1000]; Array.Copy(buffer, 0, newbuffer, 0, 999); newbuffer[999] = i; buffer = newbuffer; hybirdLock.Leave( ); } Console.WriteLine((DateTime.Now - start).TotalMilliseconds); SharpList <int> sharpList = new SharpList <int>(1000, true); start = DateTime.Now; for (int i = 0; i < 100000; i++) { sharpList.Add(i); } Console.WriteLine((DateTime.Now - start).TotalMilliseconds); int[] data = sharpList.ToArray( ); Console.ReadLine( ); }