Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Unified Diff: mojo/edk/system/ports/hash_functions.h

Issue 1585493002: [mojo] Ports EDK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/edk/system/ports/hash_functions.h
diff --git a/mojo/edk/system/ports/hash_functions.h b/mojo/edk/system/ports/hash_functions.h
new file mode 100644
index 0000000000000000000000000000000000000000..3c91cb35929db6dff200cdd1480b50946086c001
--- /dev/null
+++ b/mojo/edk/system/ports/hash_functions.h
@@ -0,0 +1,34 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_EDK_SYSTEM_PORTS_HASH_FUNCTIONS_H_
+#define MOJO_EDK_SYSTEM_PORTS_HASH_FUNCTIONS_H_
+
+#include <functional>
+
+#include "mojo/edk/system/ports/name.h"
+
+namespace std {
+
+template <>
+struct hash<mojo::edk::ports::PortName> {
+ std::size_t operator()(const mojo::edk::ports::PortName& name) const {
+ size_t h1 = hash<uint64_t>()(name.v1);
Anand Mistry (off Chromium) 2016/01/28 02:26:24 Since avoid //base doesn't appear to be a goal for
+ size_t h2 = hash<uint64_t>()(name.v2);
+ return h1 ^ (h2 << 1);
+ }
+};
+
+template <>
+struct hash<mojo::edk::ports::NodeName> {
+ std::size_t operator()(const mojo::edk::ports::NodeName& name) const {
+ size_t h1 = hash<uint64_t>()(name.v1);
+ size_t h2 = hash<uint64_t>()(name.v2);
+ return h1 ^ (h2 << 1);
+ }
+};
+
+} // namespace std
+
+#endif // MOJO_EDK_SYSTEM_PORTS_HASH_FUNCTIONS_H_

Powered by Google App Engine
This is Rietveld 408576698