Function Array.shrink

Requests the array to reduce its capacity to fit the size.

void shrink (
  size_t size
) @trusted;

The request is non-binding. The array won't become smaller than the length.

Parameters

NameDescription
size Desired size.

Example

Array!int v;
assert(v.capacity == 0);
assert(v.length == 0);

v.reserve(5);
v.insertBack(1);
v.insertBack(3);
assert(v.capacity == 5);
assert(v.length == 2);