Ensures the collection has given capacity (or more). The minimum capacity. True if preserve collection data when changing its size, otherwise collection after resize will be empty.
| 275 | /// <param name="minCapacity">The minimum capacity.</param> |
| 276 | /// <param name="preserveContents">True if preserve collection data when changing its size, otherwise collection after resize will be empty.</param> |
| 277 | void EnsureCapacity(const int32 minCapacity, const bool preserveContents = true) |
| 278 | { |
| 279 | if (_capacity < minCapacity) |
| 280 | { |
| 281 | const int32 capacity = _allocation.CalculateCapacityGrow(ToItemCapacity(_capacity), minCapacity); |
| 282 | SetCapacity(capacity, preserveContents); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | /// <summary> |
| 287 | /// Sets all items to the given value |