The OpenD Programming Language

BitArray.opApply

Support for foreach loops for BitArray.

  1. int opApply(int delegate(ref bool) dg)
  2. int opApply(int delegate(bool) dg)
  3. int opApply(int delegate(size_t, ref bool) dg)
    struct BitArray
    int
    opApply
    (
    scope int delegate
    (
    size_t
    ,
    ref bool
    )
    dg
    )
  4. int opApply(int delegate(size_t, bool) dg)

Examples

bool[] ba = [1,0,1];

auto a = BitArray(ba);

int i;
foreach (b;a)
{
    switch (i)
    {
        case 0: assert(b == true); break;
        case 1: assert(b == false); break;
        case 2: assert(b == true); break;
        default: assert(0);
    }
    i++;
}

foreach (j,b;a)
{
    switch (j)
    {
        case 0: assert(b == true); break;
        case 1: assert(b == false); break;
        case 2: assert(b == true); break;
        default: assert(0);
    }
}

Meta