Browse Source

Add [POD]Vector::IndexOf function.

Eugene Kozlov 9 years ago
parent
commit
042efb8943
1 changed files with 12 additions and 0 deletions
  1. 12 0
      Source/Urho3D/Container/Vector.h

+ 12 - 0
Source/Urho3D/Container/Vector.h

@@ -409,6 +409,12 @@ public:
         return it;
     }
 
+    /// Return index of value in vector, or size if not found.
+    unsigned IndexOf(const T& value) const
+    {
+        return Find(value) - Begin();
+    }
+
     /// Return whether contains a specific value.
     bool Contains(const T& value) const { return Find(value) != End(); }
 
@@ -989,6 +995,12 @@ public:
         return it;
     }
 
+    /// Return index of value in vector, or size if not found.
+    unsigned IndexOf(const T& value) const
+    {
+        return Find(value) - Begin();
+    }
+
     /// Return whether contains a specific value.
     bool Contains(const T& value) const { return Find(value) != End(); }