sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

Add new options to ArrayList FindString, FindValue

Open Alienmario opened this issue 1 year ago • 0 comments

Adds new optional parameters to ArrayList find natives.

  • FindString: start index, reverse search, case sensitivity
  • FindValue: start index, reverse search
int found = 0; index = -1;
while ((index = list.FindString("str-val", TestStruct::strval, index)) != -1)
{
	found++;
}

The intention is to cover most general use cases of easily and efficiently iterating over ArrayLists (including enum struct ArrayLists). The convention for the start index parameter matches that of FindEntityByClassname - startEnt. Its default of -1 allows starting from either side of the array, without manually passing the first index. Test is included in PR, tested on linux, passed.

I am still learning, so excuse any newbie mistakes. I'm open to suggestions.

Alienmario avatar Nov 03 '24 22:11 Alienmario