public AllocatedList(ListAllocator <T> allocator, int capacity) { this.allocator = allocator; ArraySegment <T> allocation = allocator.Allocate(capacity); this.array = allocation.Array; this.offset = allocation.Offset; this.capacity = capacity; this.count = 0; this.comparer = EqualityComparer <T> .Default; }
private void IncreaseCapacity(int additionalCapacity) { int newCapacity = (count + additionalCapacity) * 2; ArraySegment <T> allocation = allocator.Allocate(newCapacity); T[] newArray = allocation.Array; int newOffset = allocation.Offset; Array.Copy(array, offset, newArray, newOffset, count); array = newArray; offset = newOffset; capacity = newCapacity; }