Exemple #1
0
 void FooRefStruct(ref PointStruct pstruct)
 {
     pstruct = new PointStruct()
     {
         X = 100, Y = 200
     };
 }
Exemple #2
0
        private static float EuclidianDistance(PointStruct <float> a, PointStruct <float> b)
        {
            var dx = a.X - b.X;
            var dy = a.Y - b.Y;

            return((float)Math.Sqrt(dx * dx + dy * dy));
        }
Exemple #3
0
 void FooStruct(PointStruct pstruct)
 {
     pstruct = new PointStruct()
     {
         X = 10, Y = 20
     };
 }
        public bool WhereImmutableArrayOfStructs()
        {
            var element = new PointStruct(ElementsCount, ElementsCount);
            var result  = immutableArrayOfStructs.Contains(element);

            return(result);
        }
Exemple #5
0
            public static double PointDistanceDouble(PointStruct pointOne, PointStruct pointTwo)
            {
                double x = pointOne.X - pointTwo.X;
                double y = pointOne.Y - pointTwo.Y;

                return(Math.Sqrt((x * x) + (y * y)));
            }
Exemple #6
0
        public static double CalculateDistanceDouble(PointStruct pointA, PointStruct pointB)
        {
            double x = pointA.Xd - pointB.Xd;
            double y = pointA.Yd - pointB.Yd;

            return(Math.Sqrt(x * x + y * y));
        }
        public bool WhereListOfStructs()
        {
            var element = new PointStruct(ElementsCount, ElementsCount);
            var result  = listOfStructs.Contains(element);

            return(result);
        }
        private static RectangleClass <int> FindBestFirstLine(char[,] rect)
        {
            // O(N)

            var bestLu = new PointStruct <int>(0, 0);
            var bestRd = new PointStruct <int>(0, 0);

            var curWidth = 1;

            for (var i = 1; i < rect.GetLength(1); i++)
            {
                if (rect[0, i] == rect[0, i - 1])
                {
                    curWidth++;
                    if (curWidth > bestRd.X - bestLu.X + 1)
                    {
                        bestLu = new PointStruct <int>(i - curWidth + 1, 0);
                        bestRd = new PointStruct <int>(i, 0);
                    }
                }
                else
                {
                    curWidth = 1;
                }
            }

            return(new RectangleClass <int>(bestLu, bestRd));
        }
 static void ModifyStructPoint(PointStruct newStruct)
 {
     newStruct.x = 20;
     newStruct.y = 20;
     Console.WriteLine("Inside ModifyStructPoint()");
     Console.WriteLine("Modified values are " + newStruct.x + ", " + newStruct.y);
 }
Exemple #10
0
            public static float PointDistanceStruct(PointStruct pointOne, PointStruct pointTwo)
            {
                float x = pointOne.X - pointTwo.X;
                float y = pointOne.Y - pointTwo.Y;

                return(MathF.Sqrt((x * x) + (y * y)));
            }
Exemple #11
0
    static void Main()
    {
        PointStruct ps1 = new PointStruct();

        ps1.x = ps1.y = 22;

        PointStruct ps2 = new PointStruct();

        ps2.x = ps2.y = 33;

        ps1   = ps2;
        ps2.x = ps2.y = 55;

        Console.WriteLine("ps1 is ({0}, {1})", ps1.x, ps1.y);
        Console.WriteLine("ps2 is ({0}, {1})", ps2.x, ps2.y);
        Console.WriteLine("ps1.Equals(ps2) results in " + ps1.Equals(ps2));

        PointClass pc1 = new PointClass();

        pc1.x = pc1.y = 22;

        PointClass pc2 = new PointClass();

        pc2.x = pc2.y = 33;

        pc1   = pc2;
        pc2.x = pc2.y = 55;

        Console.WriteLine("pc1 is ({0}, {1})", pc1.x, pc1.y);
        Console.WriteLine("pc2 is ({0}, {1})", pc2.x, pc2.y);
        Console.WriteLine("pc1.Equals(pc2) results in " + pc1.Equals(pc2));
        Console.WriteLine("pc1 == pc2 results in " + (pc1 == pc2));
    }
            public static double PointDistanceDouble(PointStruct point1, PointStruct point2)
            {
                double x = point1.X - point2.X;
                double y = point1.Y - point2.Y;

                return(Math.Sqrt((x * x) + (y * y)));
            }
            public static float PointDistanceShort(PointStruct point1, PointStruct point2)
            {
                float x = point1.X - point2.X;
                float y = point1.Y - point2.Y;

                return((x * x) + (y * y));
            }
Exemple #14
0
        public static float CalculateDistanceShortFloat(PointStruct pointA, PointStruct pointB)
        {
            float x = pointA.Xf - pointB.Xf;
            float y = pointA.Yf - pointB.Yf;

            return(x * x + y * y);
        }
    static void Main()
    {
        PointStruct ps1 = new PointStruct();
        ps1.x = ps1.y = 22;

        PointStruct ps2 = new PointStruct();
        ps2.x = ps2.y = 33;

        ps1 = ps2;
        ps2.x = ps2.y = 55;

        Console.WriteLine("ps1 is ({0}, {1})", ps1.x, ps1.y);
        Console.WriteLine("ps2 is ({0}, {1})", ps2.x, ps2.y);
        Console.WriteLine("ps1.Equals(ps2) results in " + ps1.Equals(ps2));

        PointClass pc1 = new PointClass();
        pc1.x = pc1.y = 22;

        PointClass pc2 = new PointClass();
        pc2.x = pc2.y = 33;

        pc1 = pc2;
        pc2.x = pc2.y = 55;

        Console.WriteLine("pc1 is ({0}, {1})", pc1.x, pc1.y);
        Console.WriteLine("pc2 is ({0}, {1})", pc2.x, pc2.y);
        Console.WriteLine("pc1.Equals(pc2) results in " + pc1.Equals(pc2));
        Console.WriteLine("pc1 == pc2 results in " + (pc1 == pc2));
    }
        public void GlobalSetup()
        {
            arrayOfClasses         = new PointClass[ElementsCount];
            arrayOfStructs         = new PointStruct[ElementsCount];
            arrayOfReadonlyStructs = new PointReadonlyStruct[ElementsCount];
            arrayOfRecords         = new PersonRecord[ElementsCount];

            listOfClasses         = new List <PointClass>(ElementsCount);
            listOfStructs         = new List <PointStruct>(ElementsCount);
            listOfReadonlyStructs = new List <PointReadonlyStruct>(ElementsCount);
            listOfRecords         = new List <PersonRecord>(ElementsCount);

            for (int i = 0; i < ElementsCount; i++)
            {
                arrayOfClasses[i]         = new PointClass(i, i);
                arrayOfStructs[i]         = new PointStruct(i, i);
                arrayOfReadonlyStructs[i] = new PointReadonlyStruct(i, i);
                arrayOfRecords[i]         = new PersonRecord {
                    X = i, Y = i
                };

                listOfClasses.Add(new PointClass(i, i));
                listOfStructs.Add(new PointStruct(i, i));
                listOfReadonlyStructs.Add(new PointReadonlyStruct(i, i));
                listOfRecords.Add(new PersonRecord {
                    X = i, Y = i
                });

                immutableArrayOfStructs = ImmutableArray.CreateRange(arrayOfStructs);
            }
        }
        private PointStruct <int> GoFromCoin(char[,] maze, PointStruct <int> point, int mainDir, ref int curDir, out bool isOk)
        {
            if (CanGo(maze, point, mainDir))
            {
                isOk = true;
                return(Go(maze, point, mainDir));
            }
            // Else - wall
            // Implement right hand touch

            curDir = (mainDir + 4 - 1) % 4;             // Turn unit to make right hand on the wall

            for (var i = 0; i < 4; i++)
            {
                var candidateDir = (mainDir + 4 - i) % 4;
                if (CanGo(maze, point, candidateDir))
                {
                    curDir = candidateDir;
                    isOk   = true;
                    return(Go(maze, point, curDir));
                }
            }

            isOk = false;
            return(point);
        }
Exemple #18
0
        public static float CalculateDistanceFloat(PointStruct pointA, PointStruct pointB)
        {
            float x = pointA.Xf - pointB.Xf;
            float y = pointA.Yf - pointB.Yf;

            return(MathF.Sqrt(x * x + y * y));
        }
Exemple #19
0
 private static void ModifyPointStruct(PointStruct point)
 {
     point = new PointStruct(30, 60);
     Console.WriteLine("调用方法:ModifyPointStruct");
     point.X = 20;
     point.Y = 20;
     Console.WriteLine("修改成的值:x={0}, y={1}", point.X, point.Y);
 }
Exemple #20
0
        public PointStruct[] CreateArrayOfStructs()
        {
            for (int i = 0; i < ElementsCount; i++)
            {
                arrayOfStructs[i] = new PointStruct(i, i);
            }

            return(arrayOfStructs);
        }
        public void Struct()
        {
            var array = new PointStruct[ArraySize];

            for (var i = 0; i < ArraySize; i++)
            {
                array[i] = new PointStruct(1, 1);
            }
        }
Exemple #22
0
            public void TestStructfloat()
            {
                PointStruct point1 = new PointStruct();

                point1.X = X;
                PointStruct point2 = new PointStruct();

                point2.Y = Y;

                PointDistanceStruct(point1, point2);
            }
Exemple #23
0
        public PointStruct StructsByRef()
        {
            var element = new PointStruct(1, 1);

            for (int i = 0; i < ElementsCount; i++)
            {
                CalculateByRef(ref element);
            }

            return(element);
        }
        public PointStruct StructsByRef()
        {
            PointStruct element = new PointStruct(1, 1);

            for (int i = 0; i < ElementsCount; i++)
            {
                CopyStructByRef(ref element);
            }

            return(element);
        }
Exemple #25
0
            public void TestStructDouble()
            {
                PointStruct point1 = new PointStruct();

                point1.X = X;
                PointStruct point2 = new PointStruct();

                point2.Y = Y;

                PointDistanceDouble(point1, point2);
            }
        public void ToModel(double[] values)
        {
            StopLoss   = new PointStruct(range: StopLoss.Range, val: values[(int)OptimizingParameters.StopLoss]);
            TakeProfit = new PointStruct(range: TakeProfit.Range, val: values[(int)OptimizingParameters.TakeProfit]);

            Weights[0] = values[(int)OptimizingParameters.Weight0];
            Weights[1] = values[(int)OptimizingParameters.Weight1];

            Offset[0] = values[(int)OptimizingParameters.Offset0];
            Offset[1] = values[(int)OptimizingParameters.Offset1];
        }
        private PointStruct <int> Go(char[,] maze, PointStruct <int> from, int direction)
        {
            var dirArray = directions[direction];
            var to       = new PointStruct <int>(from.X + dirArray[0], from.Y + dirArray[1]);

            if (!maze.AreIndicesAllowed(to.Y, to.X))
            {
                throw new InvalidOperationException(string.Format("Not allowed to go to {0}", to));
            }
            return(to);
        }
Exemple #28
0
        //将点添加到m_pUnDoArray数组
        private void AddPointUndoArray(IPoint pPoint, double drawType, ref IArray pUndoArray)
        {
            PointStruct pointStruct = new PointStruct();

            pointStruct.Point = pPoint;

            pointStruct.Type = (int)drawType;

            pUndoArray.Add(pointStruct);

            return;
        }
 public void SendCheckedHit(bool hitResult, string atacker, PointStruct pointStruct)
 {
     Debug.Log(hitResult);
     NetClient.Send(new GamePacket
     {
         GameCommand = GameCommand.ATTACK_RECEIVE_HIT_RESULT,
         IsPointHit  = hitResult,
         PlayerId    = atacker,
         RoomId      = _runtimeManager.Room.RoomId,
         Point       = pointStruct
     });
 }
Exemple #30
0
        public void PointStructTest()
        {
            PointStruct p = new PointStruct()
            {
                X = 1, Y = 2
            };

            FooStruct(p);
            Assert.That(p.X, Is.EqualTo(1));
            FooRefStruct(ref p);
            Assert.That(p.X, Is.EqualTo(100));
            FooStruct2(p);
            Assert.That(p.X, Is.EqualTo(100));
        }
Exemple #31
0
        static void Main(string[] args) //! 활용1
        {
            PointClass pointClassA = new PointClass(10, 20);
            PointClass pointClassB = pointClassA;

            Console.WriteLine("pointClassA : " + pointClassA.x + ", " + pointClassA.y);
            Console.WriteLine("pointClassB : " + pointClassB.x + ", " + pointClassB.y);

            PointStruct pointStructA = new PointStruct(10, 20);
            PointStruct pointStructB = pointStructA;

            Console.WriteLine("pointStructA : " + pointStructA.x + ", " + pointStructA.y);
            Console.WriteLine("pointStructB : " + pointStructB.x + ", " + pointStructB.y);
        }
    static void Main()
    {
        PointStruct ps = new PointStruct();
        ps.x = ps.y = 22;

        Console.WriteLine("Before method: ps is ({0}, {1})", ps.x, ps.y);
        ChangeStructure(ps);
        Console.WriteLine("After method:  ps is ({0}, {1})", ps.x, ps.y);

        PointClass pc = new PointClass();
        pc.x = pc.y = 22;

        Console.WriteLine("Before method: pc is ({0}, {1})", pc.x, pc.y);
        ChangeClass(pc);
        Console.WriteLine("After method:  pc is ({0}, {1})", pc.x, pc.y);
    }
    static void Main()
    {
        PointStruct ps1 = new PointStruct();
        ps1.x = ps1.y = 55;

        PointStruct ps2 = new PointStruct();
        ps2.x = ps2.y = 55;

        PointClass pc1 = new PointClass();
        pc1.x = pc1.y = 55;

        PointClass pc2 = new PointClass();
        pc2.x = pc2.y = 55;

        Console.WriteLine("ps1.Equals(ps2) results in " + ps1.Equals(ps2));
        Console.WriteLine("ps1.Equals(pc1) results in " + ps1.Equals(pc1));
        Console.WriteLine("pc1.Equals(pc2) results in " + pc1.Equals(pc2));
        Console.WriteLine("pc1 == pc2 results in " + (pc1 == pc2));
        // Console.WriteLine("ps1 == ps2 results in " + (ps1 == ps2));
    }
 static void ChangeStructure(PointStruct ps)
 {
     ps.x = ps.y = 33;
 }
Exemple #35
0
 static void ModifyStructPoint(PointStruct newStruct)
 {
     newStruct.x = 20;
     newStruct.y = 20;
     Console.WriteLine("Inside ModifyStructPoint()");
     Console.WriteLine("Modified values are " + newStruct.x + ", " + newStruct.y);
 }
 /// <summary>
 /// Return a *new* point struct whose X and Y values are twice those of the input
 /// instance.
 /// </summary>
 /// <param name="pointClass"> 
 /// The input class whose X and Y to double.
 /// </param>
 /// <returns>
 /// A new instance of the point class whose X and Y values are double those of the 
 /// input.
 /// </returns>
 public PointStruct ReturnADoubledPointStruct(PointStruct pointStruct)
 {
     return new PointStruct(pointStruct.X * 2, pointStruct.Y * 2);
 }