public void TestArray(NullableLargeArray<int> array) { for (int x = 0; x < 250000; x++) { if (x >= array.Capacity) { HelperFunctions.ExpectError(() => array[x] = x); array.SetCapacity(array.Capacity + 1); } array[x] = x; } for (int x = 0; x < 250000; x++) { Assert.AreEqual(array[x], x); } }
public void TestArray(NullableLargeArray <int> array) { for (int x = 0; x < 250000; x++) { if (x >= array.Capacity) { HelperFunctions.ExpectError(() => array[x] = x); array.SetCapacity(array.Capacity + 1); } array[x] = x; } for (int x = 0; x < 250000; x++) { Assert.AreEqual(array[x], x); } }
/// <summary> /// Releases all the resources used by the <see cref="PageList"/> object. /// </summary> public void Dispose() { if (!m_disposed) { try { if (!m_memoryPool.IsDisposed) { m_memoryPool.ReleasePages(m_listOfPages.Select(x => x.MemoryPoolIndex)); m_listOfPages = null; } } catch (Exception ex) { Log.Publish(MessageLevel.Critical, "Unhandled exception when returning resources to the memory pool", null, null, ex); } finally { GC.SuppressFinalize(this); m_disposed = true; // Prevent duplicate dispose. } } }
public void TestCount() { NullableLargeArray <int> array = new NullableLargeArray <int>(); for (int x = 0; x < 100000; x++) { array.AddValue(x); } for (int x = 0; x < 100000; x += 2) { if (array[x] != x) { throw new Exception(); } array.SetNull(x); } if (array.Capacity != 100000 + (1024 - (100000 & 1023))) { throw new Exception(); } if (array.CountUsed != 50000) { throw new Exception(); } if (array.CountFree != array.Capacity - 50000) { throw new Exception(); } int i; for (int x = 1; x < 100000; x += 2) { if (!array.TryGetValue(x, out i)) { throw new Exception(); } if (i != x) { throw new Exception(); } } for (int x = 0; x < 100000; x += 2) { if (array.TryGetValue(x, out i)) { throw new Exception(); } } if (array.Count() != 50000) { throw new Exception(); } i = 1; foreach (int item in array) { if (item != i) { throw new Exception(); } i += 2; } if (array.Select(x => x).Count() != 50000) { throw new Exception(); } for (int x = 1; x < 100000; x += 2) { array.OverwriteValue(x, -1); } for (int x = 1; x < 100000; x += 2) { if (array[x] != -1) { throw new Exception(); } } }
public void TestCount() { NullableLargeArray<int> array = new NullableLargeArray<int>(); for (int x = 0; x < 100000; x++) { array.AddValue(x); } for (int x = 0; x < 100000; x += 2) { if (array[x] != x) throw new Exception(); array.SetNull(x); } if (array.Capacity != 100000 + (1024 - (100000 & 1023))) throw new Exception(); if (array.CountUsed != 50000) throw new Exception(); if (array.CountFree != array.Capacity - 50000) throw new Exception(); int i; for (int x = 1; x < 100000; x += 2) { if (!array.TryGetValue(x, out i)) throw new Exception(); if (i != x) throw new Exception(); } for (int x = 0; x < 100000; x += 2) { if (array.TryGetValue(x, out i)) throw new Exception(); } if (array.Count() != 50000) throw new Exception(); i = 1; foreach (var item in array) { if (item != i) throw new Exception(); i += 2; } if (array.Select(x => x).Count() != 50000) throw new Exception(); for (int x = 1; x < 100000; x += 2) { array.OverwriteValue(x, -1); } for (int x = 1; x < 100000; x += 2) { if (array[x] != -1) throw new Exception(); } }
/// <summary> /// Creates a new PageMetaDataList. /// </summary> /// <param name="memoryPool">The buffer pool to utilize if any unmanaged memory needs to be created.</param> public PageList(MemoryPool memoryPool) { m_memoryPool = memoryPool; m_listOfPages = new NullableLargeArray <InternalPageMetaData>(); m_pageIndexLookupByPositionIndex = new SortedList <int, int>(); }
/// <summary> /// Creates a new PageMetaDataList. /// </summary> /// <param name="memoryPool">The buffer pool to utilize if any unmanaged memory needs to be created.</param> public PageList(MemoryPool memoryPool) { m_memoryPool = memoryPool; m_listOfPages = new NullableLargeArray<InternalPageMetaData>(); m_pageIndexLookupByPositionIndex = new SortedList<int, int>(); }