コード例 #1
0
        public void ClearTest()
        {
            var list = new VSArray <int>(new[] { 0, 1, 2, 3, 4, 5, 6 });

            Assert.That(list.GetElementCount(), Is.EqualTo(7));
            list.Clear();
            Assert.That(list.GetElementCount(), Is.EqualTo(0));
        }
コード例 #2
0
        public void RemoveElementTest()
        {
            var list = new VSArray <int>(new[] { 0, 1, 2, 3, 0, 0, 4, 5 });

            Assert.That(list.GetElementCount(), Is.EqualTo(8));

            list.RemoveElement(0);
            Assert.That(list.GetElementCount(), Is.EqualTo(7));
        }
コード例 #3
0
        public void AddElementTest()
        {
            var list = new VSArray <char>(new[] { 'a', 'b', 'c', 'd', 'e' });

            Assert.That(list.GetElementCount(), Is.EqualTo(5));

            list.AddElement('f');
            Assert.That(list.GetElementCount(), Is.EqualTo(6));
            Assert.That(list.GetElement(5), Is.EqualTo('f'));
        }
コード例 #4
0
 static void DebugLog <T>(VSArray <T> list)
 {
     for (int i = 0; i < list.GetElementCount(); i++)
     {
         Debug.Log("[" + i + "]: " + list[i]);
     }
 }
コード例 #5
0
        public void RemoveElementAtTest(int[] source, int index, int[] expected)
        {
            var list = new VSArray <int>(source);

            Assert.That(list.GetElementCount(), Is.EqualTo(source.Length));

            list.RemoveElementAt(index);
            Assert.That(list, Is.EqualTo(expected.ToVSArray()));
        }
コード例 #6
0
        public static float Variance(this VSArray <float> array)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            var average = array.elements.Average();

            var variance = 0.0f;

            foreach (var value in array.elements)
            {
                variance += Mathf.Pow(value - average, 2.0f);
            }

            return(variance / array.GetElementCount());
        }
コード例 #7
0
        public void GetElementCountTest()
        {
            var list = new VSArray <int>(new[] { 1, 2, 3, 4, 5, 6 });

            Assert.That(list.GetElementCount(), Is.EqualTo(6));
        }