LinkedList.opApply

Iterating over list via foreach.

  1. int opApply(int delegate(size_t, ref T) dg)
    struct LinkedList(T, bool ordered = true)
    int
    opApply
    (
    scope int delegate
    (
    size_t
    ,
    ref T
    )
    dg
    )
  2. int opApply(int delegate(ref T) dg)

Examples

LinkedList!int list;
scope(exit) list.free();

list.append(1);
list.append(2);
list.append(3);
list.append(4);

int[4] values;

foreach(size_t i, ref int val; list) {
    values[i] = val;
}

assert(values[] == [1,2,3,4]);

Meta