当前位置: 首页>>代码示例>>C#>>正文


C# Vector.Add方法代码示例

本文整理汇总了C#中Vector.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Add方法的具体用法?C# Vector.Add怎么用?C# Vector.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector的用法示例。


在下文中一共展示了Vector.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VectorAdd

 public void VectorAdd()
 {
     Vector<Point> points = new Vector<Point>();
     points.Add(new Point(2f, 3f));
     Assert.AreEqual(1, points.Count());
     points.Add(new Point(2.4f, 3f));
     points.Add(new Point(2.5f, 3f));
     Assert.AreEqual(3, points.Count());
 }
开发者ID:danpamfil,项目名称:JuniorMind,代码行数:9,代码来源:VectorTests.cs

示例2: ItShouldBeIndexable

 public void ItShouldBeIndexable()
 {
     Vector<byte> testVector = new Vector<byte>();
     testVector.Add(1);
     testVector.Add(0);
     testVector.Add(1);
     int expected = 1;
     int actual = testVector[2];
     Assert.AreEqual(expected, actual);
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:10,代码来源:VectorTest.cs

示例3: ItShouldRemoveElements

 public void ItShouldRemoveElements()
 {
     Vector<byte> testVector = new Vector<byte>();
     testVector.Add(1);
     testVector.Add(0);
     testVector.Add(1);
     testVector.Remove(1);
     int expected = 1;
     int actual = testVector[1];
     Assert.AreEqual(expected, actual);
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:11,代码来源:VectorTest.cs

示例4: VectorRemove

        public void VectorRemove()
        {
            Point pointToRemove = new Point(2.4f, 3f);

            Vector<Point> points = new Vector<Point>();
            points.Add(new Point(2f, 3f));
            points.Add(pointToRemove);
            points.Add(new Point(2.5f, 3f));
            Assert.AreEqual(3, points.Count());
            points.Remove(pointToRemove);
            Assert.AreEqual(2, points.Count());
        }
开发者ID:danpamfil,项目名称:JuniorMind,代码行数:12,代码来源:VectorTests.cs

示例5: ItShouldHoldElements

 public void ItShouldHoldElements()
 {
     Vector<byte> actual = new Vector<byte>();
     actual.Add(1);
     actual.Add(0);
     actual.Add(1);
     Vector<byte> expected = new Vector<byte>();
     expected.Add(1);
     expected.Add(0);
     expected.Add(1);
     Assert.AreEqual(expected.ToString(), actual.ToString());
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:12,代码来源:VectorTest.cs

示例6: VectorPrev

        public void VectorPrev()
        {
            Vector<Point> points = new Vector<Point>();
            Point point = new Point(1f, 1.5f);

            points.Add(point);
            points.Add(point);
            Assert.AreEqual(point, points[1]);
            //points.Add(new Point(2f, 3f));
            //points.Add(new Point(2.4f, 3f));
            //points.Add(point);
            //points.Add(new Point(2.5f, 3f));

            //Assert.AreEqual(point, points[3].Prev.Data);
        }
开发者ID:danpamfil,项目名称:JuniorMind,代码行数:15,代码来源:VectorTests.cs

示例7: IsInBoundingBox

 protected bool IsInBoundingBox(Vector pt, Vector referencePoint, Vector relativeCenter, Vector size)
 {
     Vector boxCenter = referencePoint.Add(relativeCenter);
     return (boxCenter.X - size.X / 2 < pt.X && pt.X < boxCenter.X + size.X / 2 &&
             boxCenter.Y - size.Y / 2 < pt.Y && pt.Y < boxCenter.Y + size.Y / 2 &&
             boxCenter.Z - size.Z / 2 < pt.Z && pt.Z < boxCenter.Z + size.Z / 2);
 }
开发者ID:kingston,项目名称:camerise,代码行数:7,代码来源:BaseGesture.cs

示例8: VectorIEnumerable

        public void VectorIEnumerable()
        {
            Vector<Point> points = new Vector<Point>();
            points.Add(new Point(2f, 3f));
            points.Add(new Point(2.4f, 3f));
            points.Add(new Point(2.5f, 3f));
            points.RemoveAt(0);

            int countedPoints = 0;
            foreach (Point point in points)
            {
                countedPoints++;
            }

            Assert.AreEqual(2, countedPoints);
        }
开发者ID:danpamfil,项目名称:JuniorMind,代码行数:16,代码来源:VectorTests.cs

示例9: ItShouldBeEnumerable

 public void ItShouldBeEnumerable()
 {
     Vector<byte> testVector = new Vector<byte>();
     testVector.Add(1);
     testVector.Add(0);
     testVector.Add(1);
     int counter = 0;
     foreach (byte element in testVector)
     {
         if (element == 1)
             counter++;
     }
     int expected = 2;
     int actual = counter;
     Assert.AreEqual(expected, actual);
 }
开发者ID:bogdanuifalean,项目名称:JuniorMind,代码行数:16,代码来源:VectorTest.cs

示例10: toGrayScaleVector

 public static Vector toGrayScaleVector(this Bitmap pic)
 {
     Vector vector = new Vector();
     pic.eachPixel((pixel) => {
         vector.Add(pixel.R * 0.3 + pixel.G * 0.59 + pixel.B * 0.11);
         return 0;
     });
     return vector;
 }
开发者ID:Termina1,项目名称:diploma-svm-face-project,代码行数:9,代码来源:Extensions.cs

示例11: AddNewObject

 public void AddNewObject()
 {
     int[] localData = new int[] { 3, 7, 5, 8 };
     Vector<int> vector = new Vector<int>(localData);
     int obj = 2;
     int[] expectedValue = new int[] { 3, 7, 5, 8, 2, 0, 0, 0 };
     vector.Add(obj);
     CollectionAssert.AreEqual(expectedValue, vector.GetData());
     Assert.AreEqual(5, vector.Count());
 }
开发者ID:paulcicio,项目名称:Training,代码行数:10,代码来源:VectorTests.cs

示例12: GetDirectionForPosition

        private Direction GetDirectionForPosition(Vector position, Vector direction)
        {
            Direction resultant = new Direction();
            resultant.Value = GetPositionValue(position);
            resultant.Positions.Add(position);

            for (int i = 1; i < this.sequenceLength; i++)
            {
                Vector newPosition = position.Add(direction, i);
                resultant.Value *= GetPositionValue(newPosition);
                resultant.Positions.Add(newPosition);
            }

            return resultant;
        }
开发者ID:johannsutherland,项目名称:ProjectEuler,代码行数:15,代码来源:Program.cs

示例13: AddRaiseExceptionIfVectorsHaveDifferenteLengths

        public void AddRaiseExceptionIfVectorsHaveDifferenteLengths()
        {
            Vector vector1 = new Vector(new double[] { 1.0, 2.0, 3.0 });
            Vector vector2 = new Vector(new double[] { 4.0, 5.0, 6.0, 7.0 });

            try
            {
                vector1.Add(vector2);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(InvalidOperationException));
                Assert.AreEqual("Vectors have different lengths", ex.Message);
            }
        }
开发者ID:ajlopez,项目名称:MathelSharp,代码行数:16,代码来源:VectorTests.cs

示例14: Main

        private static void Main(String[] args)
        {
            Vector vector = Vector.Zero(3);
            Assert($"{nameof(vector)} is equal to Vector(0, 0, 0)", vector.Equals(new Vector(0, 0, 0)));
            Assert($"{nameof(vector)} is not equal to Vector(1, 1, 0)", !vector.Equals(new Vector(1, 1, 0)));

            Vector vector2 = new Vector(1, 2, 2);
            Assert($"{nameof(vector2)} length should be equal to 3.0", vector2.GetLength() == 3.0);

            Vector vector3 = new Vector(1, 1, 1);
            Vector vector4 = vector2.Add(vector3);
            Assert($"{nameof(vector2)} + {nameof(vector3)} is equal to Vector(2, 3, 3)", vector4.Equals(new Vector(2, 3, 3)));
            Assert($"{nameof(vector2)} + {nameof(vector3)} is equal to Vector(2, 3, 3)", vector4 == new Vector(2, 3, 3));

            Console.ReadKey();
        }
开发者ID:szabototo89,项目名称:szabototo89.github.io,代码行数:16,代码来源:Program.cs

示例15: OptionsForm

 public OptionsForm()
 {
     InitializeComponent();
     try
     {
         using (var reader = File.OpenText("math.default"))
         {
             var n = 0;
             var m = new Matrix<decimal>();
             var a = new Matrix<decimal>();
             var b = new Matrix<decimal>();
             var f = new Matrix<decimal>();
             var w = new Matrix<decimal>();
             for (var line = reader.ReadLine(); !string.IsNullOrWhiteSpace(line); line = reader.ReadLine())
             {
                 var arr = line.Split(' ');
                 if (arr[0][0] == 'N')
                 {
                     n = Convert.ToInt32(arr[1]);
                 }
                 else
                 {
                     var x = new Vector<decimal>();
                     for (var i = 1; i < arr.Length; i++) x.Add(Convert.ToDecimal(arr[i]));
                     if (arr[0][0] == 'M') m.Add(x);
                     if (arr[0][0] == 'A') a = new Matrix<decimal> {x};
                     if (arr[0][0] == 'B') b = new Matrix<decimal> {x};
                     if (arr[0][0] == 'F') f.Add(x);
                     if (arr[0][0] == 'W') w.Add(x);
                 }
             }
             numericUpDown1.Value = n;
             _matrixControlM.Value = m;
             _matrixControlA.Value = a;
             _matrixControlB.Value = b;
             _matrixControlF.Value = f;
             _matrixControlW.Value = w;
         }
     }
     catch (Exception ex)
     {
     }
 }
开发者ID:dprotopopov,项目名称:nonlinear,代码行数:43,代码来源:OptionsForm.cs


注:本文中的Vector.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。