public void TestEnsureExtraCapacity() { FasterList <int> listA = new FasterList <int>(); listA.IncrementCountBy(10); listA.IncreaseCapacityBy(10); Assert.That(listA.capacity, Is.EqualTo(25)); Assert.That(listA.count, Is.EqualTo(10)); }
public void TestExpandBy() { FasterList <int> list = new FasterList <int>(3); list.Add(0); list.Add(1); list.Add(2); list.IncrementCountBy(10); Assert.That(list.capacity, Is.EqualTo(19)); Assert.That(list.count, Is.EqualTo(13)); }
public void TestSet() { FasterList <int> list = new FasterList <int>(0); list.IncrementCountBy(10); for (int i = 0; i < 10; i++) { list[i] = i; } for (int i = 0; i < 10; i++) { Assert.That(list[i], Is.EqualTo(i)); } }
public void DequeueAllInto(FasterList <T> list) { uint i = (uint)list.count; list.IncrementCountBy((uint)_queue.Count); var array = list.ToArrayFast(out _); _lockQ.EnterWriteLock(); try { while (_queue.Count > 0) { array[i++] = _queue.Dequeue(); } } finally { _lockQ.ExitWriteLock(); } }