Open-GTO / foreach

foreach standalone include (non y_iterate version)
Other
22 stars 8 forks source link

Internal representation #5

Open Y-Less opened 7 years ago

Y-Less commented 7 years ago

If you don't see it on the other fork:

https://github.com/karimcambridge/SAMP-foreach/issues/10#issuecomment-333772037

For reference, your Iter_Remove:

https://github.com/Open-GTO/foreach/blob/9cca89299657c6fe27411d632e2e4f8af1279983/foreach.inc#L1543-L1561

My current one:

https://github.com/Misiur/YSI-Includes/blob/6e34cff72408958ca7f800d97eca529db2972713/YSI_Data/y_foreach/impl.inc#L426-L440

stock Iter_SafeRemove_InternalC(&count, array[], size, value, &last)
{
    if (0 <= value < size++ && array[value] > value)
    {
        // This version has reverse iterators, which need maintaining, and can
        // be used in place of a loop to jump backwards in the list.
        return
            --count,
            last = (array[(value - 1) % size] - 1) % size,
            array[last] = array[value],
            array[value] = value,
            array[(array[last] - 1) % size] = (last + 1) % size;
    }
    return INVALID_ITERATOR_SLOT;
}

(Don't know why it didn't make that link to the other repository in to a nice box).

karimcambridge commented 7 years ago

"(Don't know why it didn't make that link to the other repository in to a nice box).".

It did on chrome 61, win10.

Anyway, I did remember looking at the current YSI and attempting to use improvements just like that one, but I remember running in an issue that made me stop. I don't remember what it was though.

Y-Less commented 7 years ago

Do you see three chunks of code? I made two links - the first to this repository, which github turned in to a representation of code; the second to a different repository, which was left as a link. As a result, I manually copied the code, so two chunks are visible.

karimcambridge commented 7 years ago

http://prntscr.com/gsx2rj