private void GrowLocked(int capacity) { var newSize = UnorderedList <T> .PickGrowthSize(_Items.Length, capacity); var newItems = new InternalWorkItem <T> [newSize]; if (_Count > 0) { if (_Head < _Tail) { Array.Copy(_Items, _Head, newItems, 0, _Count); } else { Array.Copy(_Items, _Head, newItems, 0, _Items.Length - _Head); Array.Copy(_Items, 0, newItems, _Items.Length - _Head, _Tail); } } _Items = newItems; _Head = 0; _Tail = (_Count == capacity) ? 0 : _Count; }