Increases the capacity of the array, if necessary, to ensure that at least the number of elements specified by the minimum capacity argument can be stored.
This function does not increase the size of the array, ensures a memory capacity.
1 array.ensureCapacity
<array.ensureCapacity name='name'>
<minimum_capacity /> !
</array.ensureCapacity>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aname | string | Name of the variable of array type. |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Eminimum_capacity | integer | The minimum desired capacity of the array. |
Returns | |
---|---|
Type | Description |
Integer | Returns the minimum capacity indicated for the array. |
Example
Increases the minimum capacity of array.
Copy
<xsql-script name='array_ensureCapacity'> <body> <array name='cities'> <string>Barcelona</string> <string>Paris</string> <string>Roma</string> </array> <println><array.size name='cities' /></println> <array.ensureCapacity name='cities'> <number>6</number> </array.ensureCapacity> <!-- Ensure a capacity does not increases the size. --> <println><array.size name='cities' /></println> </body> </xsql-script>
The result is:
Copy
3 3