Exemple #1
0
        public void TestExpandByFromZero()
        {
            FasterList <int> list = new FasterList <int>(0);

            list.ExpandBy(10);

            Assert.That(list.capacity, Is.EqualTo(10));
            Assert.That(list.count, Is.EqualTo(10));
        }
Exemple #2
0
        public void TestEnsureExtraCapacity()
        {
            FasterList <int> listA = new FasterList <int>();

            listA.ExpandBy(10);
            listA.EnsureExtraCapacity(10);

            Assert.That(listA.capacity, Is.EqualTo(20));
            Assert.That(listA.count, Is.EqualTo(10));
        }
Exemple #3
0
        public void TestExpandBy()
        {
            FasterList <int> list = new FasterList <int>(3);

            list.Add(0);
            list.Add(1);
            list.Add(2);

            list.ExpandBy(10);

            Assert.That(list.capacity, Is.EqualTo(13));
            Assert.That(list.count, Is.EqualTo(13));
        }
Exemple #4
0
        public void DequeueAllInto(FasterList <T> list)
        {
            int i = list.Count;

            _lockQ.EnterWriteLock();
            list.ExpandBy((uint)_queue.Count);
            var array = list.ToArrayFast();

            try
            {
                while (_queue.Count > 0)
                {
                    array[i++] = _queue.Dequeue();
                }
            }
            finally
            {
                _lockQ.ExitWriteLock();
            }
        }