Function List.pushBack
Extends the List
by appending additional elements at the end of list.
size_t pushBack(R)
(
R range
) scope
if (!isList!R && isBtlInputRange!R && is(ElementEncodingType!R : ElementType));
size_t pushBack(L)
(
auto scope ref L list
) scope
if (isList!L && is(GetElementType!L : ElementType));
size_t pushBack(Val)
(
auto ref Val val
) scope
if (is(Val : ElementType));
size_t pushBack(Val)
(
auto ref Val val,
const size_t count
) scope
if (is(Val : ElementType));
Parameters
val
appended value.
list
appended list.
range
appended input renge.
Examples
{
auto list = List!(int) .build(1, 2, 3);
list .pushBack(42);
assert(list == [1, 2, 3, 42]);
}
{
auto list = List!(int) .build(1, 2, 3);
list .pushBack(only(4, 5, 6));
assert(list == [1, 2, 3, 4, 5, 6]);
}
{
auto a = List!(int) .build(1, 2, 3);
auto b = List!(int) .build(4, 5, 6);
a .pushBack(b);
assert(a == [1, 2, 3, 4, 5, 6]);
}
{
List!(int) list = List!(int) .build(1, 2, 3);
int[3] tmp = [4, 5, 6];
list .pushBack(tmp[]);
assert(list == [1, 2, 3, 4, 5, 6]);
}
{
struct Range{
int i;
bool empty()(){return i == 0;}
int front()(){return i;}
void popFront()(){i -= 1;}
//size_t length(); //no length
}
List!(int) list = List!(int) .build(6, 5, 4);
list .pushBack(Range(3));
assert(list == [6, 5, 4, 3, 2, 1]);
}