From 86c6fec890dc68ecda51a82ccdb345e7b605fcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20ASLIT=C3=9CRK?= Date: Wed, 18 Dec 2019 00:15:36 +0300 Subject: [PATCH] AK: Add Vector::find_first_index(const T&) --- AK/Vector.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AK/Vector.h b/AK/Vector.h index 012b23ae27b..2e3a13e69ee 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -527,6 +527,14 @@ public: return find([&](auto& other) { return value == other; }); } + int find_first_index(const T& value) + { + for (int i = 0; i < m_size; ++i) { + if (value == at(i)) + return i; + } + return -1; + } private: void reset_capacity() {