last ...
This commit is contained in:
@@ -7793,6 +7793,57 @@ int FindIndex(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//
|
||||
// Find Specific Item Index inside a Collection ...
|
||||
template <typename T>
|
||||
int FindIndex(
|
||||
T &item, // Item to Find
|
||||
const T &items[] // Items for Search
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Check Item Validation ...
|
||||
if (!item.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int itemsCount = ArraySize(items);
|
||||
if (itemsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < itemsCount; i++)
|
||||
{
|
||||
//
|
||||
T iItem = items[i];
|
||||
|
||||
//
|
||||
// Validate Item ...
|
||||
if (!iItem.IsValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isSame = item.IsSameAs(iItem);
|
||||
if (isSame && result <= -1)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check an Array Contains Specified Value ...
|
||||
|
||||
Reference in New Issue
Block a user