diff options
author | frosch <frosch@openttd.org> | 2009-09-14 20:59:46 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-09-14 20:59:46 +0000 |
commit | 2d9c54c9a81f5cd6f14585f9b398eef071db1c9e (patch) | |
tree | f6201ee8181448d4f652fed749e10a22f2c8fdc8 /src/core/smallvec_type.hpp | |
parent | 95dd1980532e8377a66412b55d21d5ab035d4535 (diff) | |
download | openttd-2d9c54c9a81f5cd6f14585f9b398eef071db1c9e.tar.xz |
(svn r17541) -Feature: Filtering in Add-NewGRF dialog.
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 |