Page MenuHomeFeedback Tracker

Implement some sort of findNext command
New, WishlistPublic


When using find to search through a string or array currently the found element has to be removed/renamed to be able to find following occurences:

indices = [];
bla = [5,6,7,5];
_f = bla find 5;
while {_f > -1} do {
    indices pushBack _f;
    bla set [_f, "removed"];
    _f = bla find 5;

Instead of removing/renaming the element a new find command which takes a start position for the search could be implemented (as the find command in C++).
Overloading the find command (as in C++) is not possible because both of its parameters can be an array already - new command findNext:

indices = [];
bla = [5,6,7,5];
_f = bla find 5;
while {_f > -1} do {
    indices pushBack _f;
    _f = bla findNext [5, _f + 1];


Legacy ID
Operating System
Windows 7
Feature Request
Additional Information

Event Timeline

Master85 edited Additional Information. (Show Details)
Master85 set Category to Feature Request.
Master85 set Reproducibility to N/A.
Master85 set Severity to None.
Master85 set Resolution to Open.
Master85 set Legacy ID to 2717221572.May 7 2016, 7:25 PM (extended)

does this resolve it?

I suppose you can select new range after each find operation, something like

_arr = [1,2,3,1,2,3];
_cnt = count _arr;
_ind = 0;
_from = 0;
while {_ind = _arr find 1; _ind >= 0} do {
systemChat ("found 1 at: " + str (_ind + _from));
_from = _ind + 1;
_arr = _arr select [_from, _cnt - _ind];

those commands are quite nice but they all involve copying/modifiying the source array, introducing overhead and messing up the indices (e.g. the indices are relative to the new paritally array)
so I think having a findNext command would be still an advantage

indices = [];
bla = [5,6,7,5];
if (_x isEqualTo 5) then

		indices pushBack _forEachIndex;

} forEach bla;

Master85 updated the task description. (Show Details)May 20 2016, 3:40 PM
Master85 changed Severity from None to Feature.
Master85 edited Steps To Reproduce. (Show Details)
Master85 set Operating System to Windows 7.