Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

Nope, it deffinitely has to do something with your code. For loops are the pitfalls most of the time here, because the indexing counts on even though you're removing entries from the array and thus need to stay at the same index for at least one more round. Those problems hence should occur whenever two files which should fall to your algorithm happen to follow each other directly within the array. In that case, the first one will be removed and the second one will be spared, due to the index getting counted up by the for loop. Without seeing your code it is impossible to help you though. Stay assured that no computer, nor programming language starts to skip indices in a loop from yesterday 'till today however.

URL: https://forum.audiogames.net/post/493763/#p493763




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

Are you removing the filenames from the array?When removing items from arrays, you must decrement the index, otherwise it will skip the next item.For instance, we have the following:int[] numbers = {0, 1, 2, 3, 4}for (int i=0; i if (numbers[i] > 1 and numbers[i] < 4) numbers.remove_at(i);}You might expect the above to remove 2 and 3, however, when it gets to 2, the array becomes{0, 1, 3, 4}At that moment, i still equals 2, and 3 is at index 2.Then it does i++ and does the next iteration,. Now, i=3, and 4 is at index 3.In this way, we skipped 3 entirely, because it was moved to an index we'd already checked.The way to correct this is to add i-- after removing an element from an array: if (numbers[i] >1 and numbers[i] <4) {
numbers.remove_at(i);
i--;
 } That's one possibility, , but since you're removing files, you might be deleting them from the system and leaving the array intact. In that case, the only thing I can think of is capitalization.If there is no use of to_upper_case or to_lower_case, any filenames with different case in the extentions will be skipped. Why are filenames inconsistent with case? I have no idea. It's annoying when programming.

URL: https://forum.audiogames.net/post/493768/#p493768




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

@3 that totally makes sense. Thank you for the explanation. Also, I am not deleting the actual files, just the file names as the array entries. I didn't think about the capital rule though, thanks for making me aware of that.

URL: https://forum.audiogames.net/post/493805/#p493805




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

hi,@3 is correct. I will just add, that you might also like to usecontinue;After decreasing your loop variable, in this case i. It's because after removing the item and dealing with the index, it makes no longer sense to run the loop's iteration aimed to process an item, when that item no longer exists. So continue will stop the iteration and launch nextone. Without it, if there were more conditional operations in the loop, you might end up with processing one item twice.Best regardsRastislav

URL: https://forum.audiogames.net/post/493836/#p493836




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

Hi,@3 is correct. I will just add, that you might also like to usecontinue;After decreasing your loop variable, in this case i. It's because after removing the item and dealing with the index, it makes no longer sense to run the loop's iteration aimed to process an item, when that item no longer exists. So continue will stop the iteration and launch nextone. Without it, if there were more conditional operations in the loop, you might end up with processing one item twice.Best regardsRastislav

URL: https://forum.audiogames.net/post/493836/#p493836




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

Yeah, this is generally when you'd use continue. In the example above, there was nothing else in the loop, so it would have been pointless, but it is good practice in general.

URL: https://forum.audiogames.net/post/493875/#p493875




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

Ok, thanks for the info.

URL: https://forum.audiogames.net/post/493878/#p493878




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: bgt, array for loop skips indexes

2020-01-18 Thread AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector


  


Re: bgt, array for loop skips indexes

If you start at the end of the array it is way easier. There is no need to decrement any counter indexes after removing an item. Apart from having to shuttle down the items you've already searched over (some languages will do this for you), it is way less error prone. and a way less complex algorithm.

URL: https://forum.audiogames.net/post/493943/#p493943




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector