public QuickSet(int initialCapacity, int tableSizePower, IUnmanagedMemoryPool pool, TEqualityComparer comparer) { pool.Take <T>(initialCapacity, out var span); pool.Take <int>(span.Length << tableSizePower, out var tableSpan); //No guarantee that the table is clean; clear it. tableSpan.Clear(0, tableSpan.Length); this = new QuickSet <T, TEqualityComparer>(ref span, ref tableSpan, comparer, tableSizePower); }
public QuickDictionary(int initialCapacity, int tableSizePower, IUnmanagedMemoryPool pool, TEqualityComparer comparer) { pool.Take <TKey>(initialCapacity, out var keySpan); pool.Take <TValue>(keySpan.Length, out var valueSpan); pool.Take <int>(keySpan.Length << tableSizePower, out var tableSpan); //No guarantee that the table is clean; clear it. tableSpan.Clear(0, tableSpan.Length); this = new QuickDictionary <TKey, TValue, TEqualityComparer>(ref keySpan, ref valueSpan, ref tableSpan, comparer, tableSizePower); }
public void Resize(int newSize, IUnmanagedMemoryPool pool) { var targetCapacity = pool.GetCapacityForCount <T>(newSize); if (targetCapacity != Span.Length) { var oldSet = this; pool.Take <T>(newSize, out var newSpan); pool.Take <int>(newSpan.Length << TablePowerOffset, out var newTableSpan); //There is no guarantee that the table retrieved from the pool is clean. Clear it! newTableSpan.Clear(0, newTableSpan.Length); Resize(ref newSpan, ref newTableSpan, out var oldSpan, out var oldTableSpan); oldSet.Dispose(pool); } }
public void Resize(int newSize, IUnmanagedMemoryPool pool) { var targetKeyCapacity = pool.GetCapacityForCount <TKey>(newSize); if (targetKeyCapacity != Keys.Length) { pool.Take <TKey>(newSize, out var newKeySpan); pool.Take <TValue>(newKeySpan.Length, out var newValueSpan); pool.Take <int>(newKeySpan.Length << TablePowerOffset, out var newTableSpan); //There is no guarantee that the table retrieved from the pool is clean. Clear it! newTableSpan.Clear(0, newTableSpan.Length); var oldDictionary = this; Resize(ref newKeySpan, ref newValueSpan, ref newTableSpan, out var oldKeySpan, out var oldValueSpan, out var oldTableSpan); oldDictionary.Dispose(pool); } }
public QuickQueue(int minimumInitialCount, IUnmanagedMemoryPool pool) { pool.Take(minimumInitialCount, out Span); Count = 0; CapacityMask = GetCapacityMask(Span.Length); FirstIndex = 0; LastIndex = CapacityMask; ValidateSpanCapacity(ref Span, CapacityMask); }
public void Resize(int newSize, IUnmanagedMemoryPool pool) { var targetCapacity = pool.GetCapacityForCount <T>(newSize); if (targetCapacity != Span.Length) { var oldQueue = this; pool.Take <T>(newSize, out var newSpan); Resize(ref newSpan, out var oldSpan); oldQueue.Dispose(pool); } }