made toAppendDelim better
[folly.git] / folly / Hash.h
index cc66e145205e9223b8b3af923e36b5b9b5ebbc1d..109b24e40e5478b1a2954c6b108376a02d76c9b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
 #include <utility>
 #include <tuple>
 
-#include "folly/SpookyHashV1.h"
-#include "folly/SpookyHashV2.h"
+#include <folly/SpookyHashV1.h>
+#include <folly/SpookyHashV2.h>
 
 /*
  * Various hashing functions.
@@ -59,6 +59,19 @@ inline size_t hash_combine_generic() {
   return 0;
 }
 
+template <
+    class Iter,
+    class Hash = std::hash<typename std::iterator_traits<Iter>::value_type>>
+uint64_t hash_range(Iter begin,
+                    Iter end,
+                    uint64_t hash = 0,
+                    Hash hasher = Hash()) {
+  for (; begin != end; ++begin) {
+    hash = hash_128_to_64(hash, hasher(*begin));
+  }
+  return hash;
+}
+
 template <class Hasher, typename T, typename... Ts>
 size_t hash_combine_generic(const T& t, const Ts&... ts) {
   size_t seed = Hasher::hash(t);