Function List.pushFront
Extends the List
by appending additional elements at the end of list.
size_t pushFront(R)
(
R range
) scope
if (isBtlInputRange!R && is(ElementEncodingType!R : ElementType));
size_t pushFront(L)
(
auto scope ref L list
) scope
if (isList!L && is(GetElementType!L : ElementType));
size_t pushFront(Val)
(
auto ref Val val
) scope
if (is(Val : ElementType));
size_t pushFront(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 .pushFront(42);
assert(list == [42, 1, 2, 3]);
}
{
auto list = List!(int) .build(1, 2, 3);
list .pushFront(only(4, 5, 6));
assert(list == [6, 5, 4, 1, 2, 3]);
}
{
auto a = List!(int) .build(1, 2, 3);
auto b = List!(int) .build(4, 5, 6);
a .pushFront(b);
assert(a == [6, 5, 4, 1, 2, 3]);
}
{
List!(int) list = List!(int) .build(1, 2, 3);
int[3] tmp = [4, 5, 6];
list .pushFront(tmp[]);
assert(list == [6, 5, 4, 1, 2, 3]);
}
{
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 .pushFront(Range(3));
assert(list == [1, 2, 3, 6, 5, 4]);
}