I have this array: TArray<FQuestInfo> QuestList;
If I am iterating through it in this manner:
int32 AQuestManager::GetQuestIndex(FName questID)
{
for (FQuestInfo& quest : QuestList)
{
if (quest.QuestID == questID)
{
return // need to return index of iterator here
}
else
{
return -1;
}
}
}
How do I obtain the index with this method of iteration? Or is it just necessary to use a different method?
If so, can anyone recommend me the best/most efficient way to iterate through a TArray to be able to both get the indices if needed, or perform action on the items in the array?
I found this method on this UE4 blog that’s dated 2014: Range-Based For Loops - Unreal Engine