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)); }
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)); }
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')); }
static void DebugLog <T>(VSArray <T> list) { for (int i = 0; i < list.GetElementCount(); i++) { Debug.Log("[" + i + "]: " + list[i]); } }
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())); }
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()); }
public void GetElementCountTest() { var list = new VSArray <int>(new[] { 1, 2, 3, 4, 5, 6 }); Assert.That(list.GetElementCount(), Is.EqualTo(6)); }