From 2c4af740c7492cf1cf3568980dfce1b5b09d1911 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Thu, 11 Jul 2019 14:05:22 +0200 Subject: [PATCH] AK: Add operator== & operator!= to Vector --- AK/Vector.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/AK/Vector.h b/AK/Vector.h index 2de470a3830..698c23da0bf 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -147,6 +147,24 @@ public: m_size = 0; } + bool operator==(const Vector& other) const + { + if (m_size != other.m_size) + return false; + + for (int i = 0; i < m_size; ++i) { + if (at(i) != other.at(i)) + return false; + } + + return true; + } + + bool operator!=(const Vector& other) const + { + return !(*this == other); + } + bool contains_slow(const T& value) const { for (int i = 0; i < size(); ++i) {