diff options
Diffstat (limited to 'src/core/smallvec_type.hpp')
-rw-r--r-- | src/core/smallvec_type.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index b3a1e3e65..82ade860c 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -116,6 +116,24 @@ public: } /** + * Search for the first occurence of an item. + * The '!=' operator of T is used for comparison. + * @param item Item to search for + * @return The position of the item, or -1 when not present + */ + FORCEINLINE int FindIndex(const T &item) + { + int index = 0; + T *pos = this->Begin(); + const T *end = this->End(); + while (pos != end && *pos != item) { + pos++; + index++; + } + return pos == end ? -1 : index; + } + + /** * Tests whether a item is present in the vector. * The '!=' operator of T is used for comparison. * @param item Item to test for |