浏览代码

LibGfx/Point: Add hash trait for Point<T>

Mustafa Quraish 3 年之前
父节点
当前提交
522f0841fd
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      Userland/Libraries/LibGfx/Point.h

+ 9 - 0
Userland/Libraries/LibGfx/Point.h

@@ -267,3 +267,12 @@ bool encode(Encoder&, Gfx::IntPoint const&);
 bool decode(Decoder&, Gfx::IntPoint&);
 
 }
+
+template<typename T>
+struct AK::Traits<Gfx::Point<T>> : public AK::GenericTraits<Gfx::Point<T>> {
+    static constexpr bool is_trivial() { return false; }
+    static unsigned hash(Gfx::Point<T> const& point)
+    {
+        return pair_int_hash(AK::Traits<T>::hash(point.x()), AK::Traits<T>::hash(point.y()));
+    }
+};