Parcourir la source

GModelIndex: Add hash traits so we can make a HashTable<GModelIndex>

Andreas Kling il y a 6 ans
Parent
commit
19b69741ed
1 fichiers modifiés avec 8 ajouts et 1 suppressions
  1. 8 1
      Libraries/LibGUI/GModelIndex.h

+ 8 - 1
Libraries/LibGUI/GModelIndex.h

@@ -1,7 +1,7 @@
 #pragma once
 
-#include <AK/String.h>
 #include <AK/LogStream.h>
+#include <AK/String.h>
 
 class GModel;
 
@@ -48,3 +48,10 @@ inline const LogStream& operator<<(const LogStream& stream, const GModelIndex& v
 {
     return stream << String::format("GModelIndex(%d,%d)", value.row(), value.column());
 }
+
+namespace AK {
+template<>
+struct Traits<GModelIndex> : public GenericTraits<GModelIndex> {
+    static unsigned hash(const GModelIndex& index) { return pair_int_hash(index.row(), index.column()); }
+};
+}