Changes the capacity of the collection. The new capacity. True if preserve collection data when changing its size, otherwise collection after resize will be empty.
| 383 | /// <param name="capacity">The new capacity.</param> |
| 384 | /// <param name="preserveContents">True if preserve collection data when changing its size, otherwise collection after resize will be empty.</param> |
| 385 | void SetCapacity(const int32 capacity, const bool preserveContents = true) |
| 386 | { |
| 387 | if (capacity == _capacity) |
| 388 | return; |
| 389 | ASSERT(capacity >= 0); |
| 390 | const int32 count = preserveContents ? (_count < capacity ? _count : capacity) : 0; |
| 391 | _allocation.Relocate(capacity, _count, count); |
| 392 | _capacity = capacity; |
| 393 | _count = count; |
| 394 | } |
| 395 | |
| 396 | /// <summary> |
| 397 | /// Resizes the collection to the specified size. If the size is equal or less to the current capacity no additional memory reallocation in performed. |