String intern table and support for unordered_map

Change-Id: I22d86d060780552675c5d7f14a98ffde480eac82
diff --git a/src/unordered_map.h b/src/unordered_map.h
new file mode 100644
index 0000000..66613c6
--- /dev/null
+++ b/src/unordered_map.h
@@ -0,0 +1,37 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+
+#ifndef ART_SRC_CLASS_UNORDERED_MAP_H_
+#define ART_SRC_CLASS_UNORDERED_MAP_H_
+
+#include "stringpiece.h"
+
+#ifdef __ANDROID__
+#include <unordered_map>
+#else
+#include <tr1/unordered_map>
+#endif
+
+namespace std {
+#ifndef __ANDROID__
+namespace tr1 {
+#endif
+template<>
+struct hash<art::StringPiece> {
+ public:
+  size_t operator()(const art::StringPiece& string_piece) const {
+    size_t string_size = string_piece.size();
+    const char* string_data = string_piece.data();
+    // this is the java.lang.String hashcode for convenience, not interoperability
+    size_t hash = 0;
+    while (string_size--) {
+      hash = hash * 31 + *string_data++;
+    }
+    return hash;
+  }
+};
+#ifndef __ANDROID__
+}  // namespace tr1
+#endif
+}  // namespace std
+
+#endif  // ART_SRC_CLASS_UNORDERED_MAP_H_