Iterator.opApply

Foreach support with counter

Instead of remembering the exact pointer we last iterated upon a break, we remember the index within the linked list and re-iterate to that index next time we're called. Using a pointer for this problem would be problematic, probably (alliteration!), because the linked list could change drastically in the mean time. Elements could be removed, especially the one we were remembering. adding checks to make that safe is a lot of hassle and not worth it.

As buckets are supposed to be very small anyway, we just remember the index and if the list finished before we reach that index, so be it, we just use the next bucket then.

  1. int opApply(int delegate(ref Bucket.Element element) dg)
  2. int opApply(int delegate(ref size_t i, ref Bucket.Element element) dg)
    class Iterator
    protected final
    int
    opApply
    (
    scope int delegate
    (
    ref size_t i
    ,)
    dg
    )

Meta