Hey, I'm Karim Cambridge aka Kar.
I love all things programming & problem solving.
I have no main focus but JavaScript is my current โค๏ธ, some say full stack doesn't exist but I take the stack to the moon.
foreach standalone include (non y_iterate version)
License: Other
Hey, I'm Karim Cambridge aka Kar.
I love all things programming & problem solving.
I have no main focus but JavaScript is my current โค๏ธ, some say full stack doesn't exist but I take the stack to the moon.
new Iterator:Pickup[1000]<MAX_PLAYERS>;
Same for:
new IteratorArray:Pickup[1000]<MAX_PLAYERS>;
And for:
new Iterator:Pickup<MAX_PLAYERS>;
Hey.
I think this is not my fault.
new Iterator:ServerItems<500>;
public Timer_2()
{
foreach(new serveritemid : ServerItems)
{
count[serveritemid]++;
if(count[serveritemid] == 2)
{
new current = serveritemid;
Iter_SafeRemove(ServerItems, current, serveritemid);
printf("removing %d || next: %d || current serverItems %d", current, serveritemid, Iter_Count(ServerItems));
}
printf("current id %d || current serverItems %d", serveritemid, Iter_Count(ServerItems));
}
}
output:
[2017/10/01 21:56:25] current id 0 || current serverItems 7
[2017/10/01 21:56:25] current id 1 || current serverItems 7
[2017/10/01 21:56:25] current id 2 || current serverItems 7
[2017/10/01 21:56:25] current id 3 || current serverItems 7
[2017/10/01 21:56:25] current id 4 || current serverItems 7
[2017/10/01 21:56:25] current id 5 || current serverItems 7
[2017/10/01 21:56:25] current id 6 || current serverItems 7
[2017/10/01 21:56:27] removing 0 || next: 500 || current serverItems 6
[2017/10/01 21:56:27] current id 500 || current serverItems 6
[2017/10/01 21:56:27] removing 1 || next: 500 || current serverItems 5
[2017/10/01 21:56:27] current id 500 || current serverItems 5
[2017/10/01 21:56:27] removing 2 || next: 0 || current serverItems 4
[2017/10/01 21:56:27] current id 0 || current serverItems 4
[2017/10/01 21:56:27] removing 3 || next: 1 || current serverItems 3
[2017/10/01 21:56:27] current id 1 || current serverItems 3
[2017/10/01 21:56:27] removing 4 || next: 2 || current serverItems 2
[2017/10/01 21:56:27] current id 2 || current serverItems 2
[2017/10/01 21:56:27] removing 5 || next: 3 || current serverItems 1
[2017/10/01 21:56:27] current id 3 || current serverItems 1
[2017/10/01 21:56:27] removing 6 || next: 4 || current serverItems 0
[2017/10/01 21:56:27] current id 4 || current serverItems 0
[2017/10/01 21:56:30] current id 2 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
[2017/10/01 21:56:30] current id 5 || current serverItems 0
`
i tried to follow that method that you can see in this topic http://forum.sa-mp.com/showthread.php?t=570937
The reason that won't work is that the loop needs to use the current slot to get
the next slot, but we just removed the current slot so it is no longer valid for
getting the next slot. Instead, we use "Iter_SafeRemove", which takes an
additional parameter to store the next slot in BEFORE the current slot is
removed:
foreach (new i : MyIter)
{
new
cur = i;
if (cur == 5)
{
Iter_SafeRemove(MyIter, cur, i);
}
printf("%d", i);
}
[2017/10/01 22:27:06] 0
[2017/10/01 22:27:06] 1
[2017/10/01 22:27:06] 2
[2017/10/01 22:27:06] 3
[2017/10/01 22:27:06] 4
[2017/10/01 22:27:06] 4 // twice?
[2017/10/01 22:27:06] 6
[2017/10/01 22:27:09] 0
[2017/10/01 22:27:09] 1
[2017/10/01 22:27:09] 2
[2017/10/01 22:27:09] 3
[2017/10/01 22:27:09] 4
[2017/10/01 22:27:09] 6
and it wont crash. But if i add some condition like theese;
foreach (new i : MyIter)
{
count[i]++;
if(count[i] == 2)
{
new cur = i;
Iter_SafeRemove(MyIter, cur, i);
}
printf("%d", i);
}
the result will be
[2017/10/01 22:20:51] 0
[2017/10/01 22:20:51] 1
[2017/10/01 22:20:51] 2
[2017/10/01 22:20:51] 3
[2017/10/01 22:20:51] 4
[2017/10/01 22:20:51] 5
[2017/10/01 22:20:51] 6
[2017/10/01 22:20:53] 500
[2017/10/01 22:20:53] 500
[2017/10/01 22:20:53] 0
[2017/10/01 22:20:53] 1
[2017/10/01 22:20:53] 2
[2017/10/01 22:20:53] 3
[2017/10/01 22:20:53] 4
[2017/10/01 22:20:56] 2
Tried to compile your standalone version of foreach but got two warnings. Stated below.
warning 201: redefinition of constant/macro (symbol "_Y_ITER_C2:sizeof%0(%1)@YSII_Ag-1;_:(%2=_Y_ITER_ARRAY:%3(%4)@YSII_Ag[%5])!=%9_Y_ITER_ARRAY_SIZE(%6);)")
warning 201: redefinition of constant/macro (symbol "_Y_ITER_C3:%0[%1]@YSII_Cg,%2[%3]@YSII_Ag[%4]={%5}")
Tried resorting my #include order but to no avail.
EDIT: Above fixed, found another warning after above was fixed.
error 031: unknown directive (at line 224)
Hola tengo un problema, que es cuando intento declarar un nuevo IteratorArray me da el siguiente error
(718) : error 001: expected token: "-identifier-", but found "-integer value-"
The line is..
new IteratorArray:InEdificio[MAX_EDIFICIORENTA]<MAX_PLAYERS>;
I just want to know why this happens?
I dont need NPC and Characters iterators and i use FOREACH_NO_BOTS but from last updates its not working anymore
F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(619) : error 017: undefined symbol "Bot@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(619) : error 017: undefined symbol "Bot@YSII_Ag" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(620) : error 017: undefined symbol "Character@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(620) : error 017: undefined symbol "Character@YSII_Ag" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(718) : error 017: undefined symbol "Bot@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(718) : error 017: undefined symbol "Bot@YSII_Ag" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(719) : error 017: undefined symbol "Character@YSII_Cg" F:\Stuff\V1-1.1.1\pawno\include\foreach.inc(719) : error 017: undefined symbol "Character@YSII_Ag"
Give me this errors , any way to fix it? Or i need to get rid of define?
Hi,
Firstly, thanks for adding me to the repository (somewht out of the blue - I was not expecting that at all), and thanks for maintaining this (working on two subtly different ones was a pain, and frequently resulted in regressions or bugs in one but not the other).
Anyway, as you added me here, I'm wondering where you are taking this version? y_iterate has moved on a lot since this version was forked. A lot of the changes probably can't be back-ported easilly as they would introduce huge extra dependencies (especially the new yield
keyword); however, the other one is now very well tested, so I was wondering how much of that newer stuff you wanted to pull in, and how much you wanted me for that?
I think foreach_04.02.2014.inc should be in another branch.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.