コード例 #1
0
        public void RemoveAtIfEmpty()
        {
            using var list = new PoolingListCanon <object>();

            Assert.AreEqual(0, list.Count);
            Assert.Throws <IndexOutOfRangeException>(() => { list.RemoveAt(0); });
        }
コード例 #2
0
        public void RemoveIfEmpty()
        {
            using var list = new PoolingListCanon <object>();

            Assert.AreEqual(0, list.Count);
            Assert.AreEqual(false, list.Remove(29));
        }
コード例 #3
0
 public void TestEmpty()
 {
     using (var list = new PoolingListCanon <object>())
     {
         Assert.AreEqual(0, list.Count);
         Assert.AreEqual(false, list.IsReadOnly);
         Assert.AreEqual(-1, list.IndexOf(1));
     }
 }
コード例 #4
0
        public void SingleAdditionAndRemoveAt()
        {
            using var list = new PoolingListCanon <object>();
            list.Add(30);
            list.RemoveAt(0);

            Assert.AreEqual(0, list.Count);
            Assert.Throws <IndexOutOfRangeException>(() => { var _ = list[0]; });
        }
コード例 #5
0
        public void SingleAddition()
        {
            using (var list = new PoolingListCanon <object>())
            {
                list.Add(30);

                Assert.AreEqual(1, list.Count);
                Assert.AreEqual(30, list[0]);
            }
        }
コード例 #6
0
        public void AllAdditions()
        {
            using (var list = new PoolingListCanon <object>())
            {
                for (int i = 0; i < LocalList <int> .LocalStoreCapacity; i++)
                {
                    list.Add(i * 10);
                }

                Assert.AreEqual(LocalList <int> .LocalStoreCapacity, list.Count);
            }
        }
コード例 #7
0
 private void Dispose()
 {
     if (_count == 0)
     {
         return;
     }
     _count--;
     if (_count == 0)
     {
         _src?.Dispose();
         _src = default;
         Pool <EnumerableShared <T> > .Return(this);
     }
 }
コード例 #8
0
        public void MakeListFromValueTuple()
        {
            using var list = new PoolingListCanon <object>();
            list.Add(10);
            list.Add(20);
            list.Add(30);


            Assert.AreEqual(3, list.Count);
            Assert.AreEqual(10, list[0]);
            Assert.AreEqual(20, list[1]);
            Assert.AreEqual(30, list[2]);

            Assert.Throws <IndexOutOfRangeException>(() => { var _ = list[3]; });
        }
コード例 #9
0
 public IPoolingEnumerable <T> Init(PoolingListCanon <T> src)
 {
     _src   = src;
     _count = 0;
     return(this);
 }