List.pushFront

Extends the List by appending additional elements at the end of list.

  1. size_t pushFront(R range)
  2. size_t pushFront(L list)
    struct List
    scope
    size_t
    pushFront
    (
    L
    )
    (
    scope auto ref L list
    )
    if (
    isList!L &&
    is(GetElementType!L : ElementType)
    )
  3. size_t pushFront(Val val)
  4. size_t pushFront(Val val, size_t count)

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]);
}

Meta