Function Vector.resize

Resizes the vector to a length of n elements.

void resize(Args...) (
  const size_t n,
  auto ref Args args
) scope;

If n is smaller than the current vector length, the current value is shortened to its first n character, removing the characters beyond the nth.

If n is greater than the current vector length, the current content is extended by inserting at the end as many elements as needed to reach a size of n.

If args are specified, the new elements are emplaced with parameters args, otherwise, they are ElementType.init.

Examples

Vector!(int, 6) vec = Vector!(int, 6).build(1, 2, 3);

vec.resize(5, 0);
assert(vec == [1, 2, 3, 0, 0]);

vec.resize(2);
assert(vec == [1, 2]);