ensure ( n seq -- n seq )


Vocabulary
growable

Inputs
na non-negative integer
seqa growable


Outputs
na non-negative integer
seqa growable


Word description
Ensures that seq has sufficient capacity to store an n th element.

This word behaves as follows, depending on the relation between n, the capacity of the underlying storage, and the length of the sequence:
If n is less than the length of the sequence, does nothing.
If n is greater than or equal to the capacity of the underlying storage, the underlying storage is grown.
If n is greater than or equal to the length, the length is increased.

In the case that new elements are added to the sequence (last two cases), the new elements are undefined.

Notes
This word is used in the implementation of the set-nth generic for sequences supporting the resizable sequence protocol (see Resizable sequence implementation ).

Definition