mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Add overload to search array with a different type without casting
* Provided a compatible operator== overload exists, this can still be used to search the array.
This commit is contained in:
@@ -655,7 +655,7 @@ void AddRecentFile(rdcarray<rdcstr> &recentList, const rdcstr &file)
|
||||
return;
|
||||
}
|
||||
|
||||
if(recentList.contains(path))
|
||||
if(recentList.contains(rdcstr(path)))
|
||||
recentList.removeOne(path);
|
||||
|
||||
recentList.push_back(path);
|
||||
|
||||
@@ -638,8 +638,25 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
template <class U>
|
||||
int32_t indexOf(const U &el, size_t first = 0, size_t last = ~0U) const
|
||||
{
|
||||
for(size_t i = first; i < usedCount && i < last; i++)
|
||||
{
|
||||
if(elems[i] == el)
|
||||
return (int32_t)i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// return true if an element is found
|
||||
bool contains(const T &el) const { return indexOf(el) != -1; }
|
||||
template <class U>
|
||||
bool contains(const U &el) const
|
||||
{
|
||||
return indexOf(el) != -1;
|
||||
}
|
||||
// remove the first occurrence of an element
|
||||
void removeOne(const T &el)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user