Alias Array.insert
Inserts the el into the array.
Parameters
Name | Description |
---|---|
R | Type of the inserted value(s) (single value, range or static array). |
el | Value(s) should be inserted. |
Returns
The number of elements inserted.
Example
struct TestRange
{
int counter = 6;
int front()
{
return counter;
}
void popFront()
{
counter -= 2;
}
bool empty()
{
return counter == 0;
}
}
Array!int v1;
assert(v1 .insertBack(5) == 1);
assert(v1 .length == 1);
assert(v1 .capacity == 1);
assert(v1 .back == 5);
assert(v1 .insertBack(TestRange()) == 3);
assert(v1 .length == 4);
assert(v1 .capacity == 4);
assert(v1[0] == 5 && v1[1] == 6 && v1[2] == 4 && v1[3] == 2);
assert(v1 .insertBack([34, 234]) == 2);
assert(v1 .length == 6);
assert(v1 .capacity == 6);
assert(v1[4] == 34 && v1[5] == 234);