resize method
Resizes the Vec in-place so that len is equal to newLen
.
If newLen
is greater than len, the Vec is extended by the difference,
with each additional slot filled with value. If new_len is less than len,
the Vec is simply truncated.
Implementation
void resize(int newLen, T value) {
if (newLen > length) {
final doFor = newLen - length;
for (int i = 0; i < doFor; i++) {
add(value);
}
} else {
length = newLen;
}
}