コード例 #1
0
        public void RemoveTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            for (int i = 1; i <= 10; i++)
            {
                UnsafeList.Add(arr, i);
            }

            Assert.AreEqual(10, UnsafeList.GetCount(arr));

            UnsafeList.RemoveAt(arr, 4); //Remove number 5
            Assert.AreEqual(9, UnsafeList.GetCount(arr));

            int offs = 0;

            for (int i = 1; i < 10; i++)
            {
                if (i == 5)
                {
                    offs++;         //Skip previously removed 5
                }
                var num = UnsafeList.Get <int>(arr, i - 1);
                Assert.AreEqual(i + offs, num);
            }
        }
コード例 #2
0
        public void ConstructorTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            Assert.AreEqual(UnsafeList.GetCount(arr), 0);

            UnsafeList.Free(arr);
        }
コード例 #3
0
        public void InvalidTypeTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            Assert.Catch <AssertException>(() => { UnsafeList.Set <float>(arr, 4, 20); });

            UnsafeList.Free(arr);
        }
コード例 #4
0
        public void LastIndexOfTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            for (int i = 1; i <= 10; i++)
            {
                UnsafeList.Add(arr, i);
            }

            Assert.AreEqual(4, UnsafeList.LastIndexOf(arr, 5));
            Assert.AreEqual(-1, UnsafeList.LastIndexOf(arr, 645));
            Assert.AreEqual(9, UnsafeList.LastIndexOf(arr, 10));
        }
コード例 #5
0
        public void IndexOfTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            for (int i = 1; i <= 10; i++)
            {
                UnsafeList.Add(arr, i);
            }

            var index = UnsafeList.IndexOf(arr, 5);

            Assert.AreEqual(4, index);
        }
コード例 #6
0
        public void MutateTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            for (int i = 0; i < 10; i++)
            {
                UnsafeList.Add(arr, i);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i, UnsafeList.Get <int>(arr, i));
            }

            UnsafeList.Free(arr);
        }
コード例 #7
0
        public void IteratorTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            var itr = UnsafeList.GetEnumerator <int>(arr);

            for (int i = 0; i < 10; i++)
            {
                UnsafeList.Add(arr, i * i);
            }

            Assert.AreEqual(10, UnsafeList.GetCount(arr));

            int num = 0;

            foreach (int i in itr)
            {
                Assert.AreEqual(num * num, i);
                num++;
            }

            UnsafeList.Free(arr);
        }
コード例 #8
0
 public NativeList(int capacity, bool fixedSize)
 {
     m_inner = UnsafeList.Allocate <T>(capacity, fixedSize);
 }
コード例 #9
0
 public NativeList(int capacity)
 {
     m_inner = UnsafeList.Allocate <T>(capacity, false);
 }