From beb77d0e2da4ce0f203d63f4687e2c21369cc77e Mon Sep 17 00:00:00 2001 From: Davi de Castro Reis Date: Thu, 10 Nov 2011 16:44:37 -0200 Subject: [PATCH] Removed tr1 stuff. --- cxxmph/bm_common.h | 4 +-- cxxmph/bm_index.cc | 8 +++--- cxxmph/bm_map.cc | 58 ++++++++++++++++++++++---------------------- cxxmph/mph_index.h | 4 +-- cxxmph/mph_map.h | 6 ++--- cxxmph/mph_table.h | 16 ------------ cxxmph/seeded_hash.h | 32 ++++++++++++------------ cxxmph/stringpiece.h | 1 + 8 files changed, 56 insertions(+), 73 deletions(-) delete mode 100644 cxxmph/mph_table.h diff --git a/cxxmph/bm_common.h b/cxxmph/bm_common.h index fc95b21..ad8466e 100644 --- a/cxxmph/bm_common.h +++ b/cxxmph/bm_common.h @@ -2,19 +2,17 @@ #include #include -#include // for std::tr1::hash +#include // std::hash #include "MurmurHash2.h" #include "benchmark.h" namespace std { -namespace tr1 { template <> struct hash { uint32_t operator()(const cxxmph::StringPiece& k) const { return cxxmph::MurmurHash2(k.data(), k.length(), 1); } }; -} // namespace tr1 } // namespace std namespace cxxmph { diff --git a/cxxmph/bm_index.cc b/cxxmph/bm_index.cc index f92972b..84bf7d2 100644 --- a/cxxmph/bm_index.cc +++ b/cxxmph/bm_index.cc @@ -1,6 +1,6 @@ #include #include -#include +#include #include "bm_common.h" #include "stringpiece.h" @@ -9,7 +9,7 @@ using namespace cxxmph; using std::string; -using std::tr1::unordered_map; +using std::unordered_map; class BM_MPHIndexCreate : public UrlsBenchmark { public: @@ -35,7 +35,7 @@ class BM_STLIndexCreate : public UrlsBenchmark { } } }; - + class BM_MPHIndexSearch : public SearchUrlsBenchmark { public: BM_MPHIndexSearch(const std::string& urls_file, int nsearches) @@ -76,7 +76,7 @@ class BM_STLIndexSearch : public SearchUrlsBenchmark { index.swap(index_); return true; } - std::tr1::unordered_map index_; + std::unordered_map index_; }; int main(int argc, char** argv) { diff --git a/cxxmph/bm_map.cc b/cxxmph/bm_map.cc index 95e76f7..607edc6 100644 --- a/cxxmph/bm_map.cc +++ b/cxxmph/bm_map.cc @@ -4,38 +4,38 @@ #include "bm_common.h" #include "mph_map.h" -using cxxmph::mph_map; -using std::string; -using std::tr1::unordered_map; + using cxxmph::mph_map; + using std::string; + using std::unordered_map; -namespace cxxmph { + namespace cxxmph { -uint64_t myfind(const unordered_map& mymap, const uint64_t& k) { - return mymap.find(k)->second; -} - -uint64_t myfind(const mph_map& mymap, const uint64_t& k) { - return mymap.find(k)->second; -} - -const StringPiece& myfind(const unordered_map& mymap, const StringPiece& k) { - return mymap.find(k)->second; -} -StringPiece myfind(const mph_map& mymap, const StringPiece& k) { - auto it = mymap.find(k); - return it->second; -} - -template -class BM_CreateUrls : public UrlsBenchmark { - public: - BM_CreateUrls(const string& urls_file) : UrlsBenchmark(urls_file) { } - virtual void Run() { - MapType mymap; - for (auto it = urls_.begin(); it != urls_.end(); ++it) { - mymap[*it] = *it; - } + uint64_t myfind(const unordered_map& mymap, const uint64_t& k) { + return mymap.find(k)->second; } + + uint64_t myfind(const mph_map& mymap, const uint64_t& k) { + return mymap.find(k)->second; + } + + const StringPiece& myfind(const unordered_map& mymap, const StringPiece& k) { + return mymap.find(k)->second; + } + StringPiece myfind(const mph_map& mymap, const StringPiece& k) { + auto it = mymap.find(k); + return it->second; + } + + template + class BM_CreateUrls : public UrlsBenchmark { + public: + BM_CreateUrls(const string& urls_file) : UrlsBenchmark(urls_file) { } + virtual void Run() { + MapType mymap; + for (auto it = urls_.begin(); it != urls_.end(); ++it) { + mymap[*it] = *it; + } + } }; template diff --git a/cxxmph/mph_index.h b/cxxmph/mph_index.h index 70cee68..3ee9090 100644 --- a/cxxmph/mph_index.h +++ b/cxxmph/mph_index.h @@ -26,7 +26,7 @@ #include #include -#include // for std::tr1::hash +#include // for std::hash #include #include @@ -201,7 +201,7 @@ uint32_t MPHIndex::index(const Key& key) const { // Simple wrapper around MPHIndex to simplify calling code. Please refer to the // MPHIndex class for documentation. -template >::hash_function> +template >::hash_function> class SimpleMPHIndex : public MPHIndex { public: template diff --git a/cxxmph/mph_map.h b/cxxmph/mph_map.h index bcfebb6..23407d4 100644 --- a/cxxmph/mph_map.h +++ b/cxxmph/mph_map.h @@ -6,7 +6,7 @@ // use it for educational purposes. #include -#include +#include #include #include // for std::pair @@ -15,14 +15,14 @@ namespace cxxmph { -using std::tr1::unordered_map; +using std::unordered_map; // Save on repetitive typing. #define MPH_MAP_TMPL_SPEC template #define MPH_MAP_CLASS_SPEC mph_map #define MPH_MAP_METHOD_DECL(r, m) MPH_MAP_TMPL_SPEC typename MPH_MAP_CLASS_SPEC::r MPH_MAP_CLASS_SPEC::m -template , class EqualKey = std::equal_to, class Alloc = std::allocator > +template , class EqualKey = std::equal_to, class Alloc = std::allocator > class mph_map { public: typedef Key key_type; diff --git a/cxxmph/mph_table.h b/cxxmph/mph_table.h deleted file mode 100644 index 234540d..0000000 --- a/cxxmph/mph_table.h +++ /dev/null @@ -1,16 +0,0 @@ -#include "mph_index.h" - -// String to string map working on mmap'ed memory - -class MPHTable { - public: - typedef StringPiece key_type; - typedef StringPiece data_type; - typedef std::pair value_type; - template - bool Reset(ForwardIterator begin, ForwardIterator end); - private: - char* data_; - vector offsets_; - MPHIndex index_; -}; diff --git a/cxxmph/seeded_hash.h b/cxxmph/seeded_hash.h index a12d4f8..64cb74d 100644 --- a/cxxmph/seeded_hash.h +++ b/cxxmph/seeded_hash.h @@ -4,7 +4,7 @@ #include // for uint32_t and friends #include -#include // for std::tr1::hash +#include // for std::hash #include "MurmurHash2.h" #include "stringpiece.h" @@ -59,36 +59,36 @@ struct seeded_hash_function { template struct seeded_hash { typedef seeded_hash_function hash_function; }; -// Use Murmur2 instead for all types defined in std::tr1::hash, plus +// Use Murmur2 instead for all types defined in std::hash, plus // std::string which is commonly extended. -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; -template <> struct seeded_hash > +template <> struct seeded_hash > { typedef seeded_hash_function hash_function; }; } // namespace cxxmph diff --git a/cxxmph/stringpiece.h b/cxxmph/stringpiece.h index f1327ea..06cea3a 100644 --- a/cxxmph/stringpiece.h +++ b/cxxmph/stringpiece.h @@ -19,6 +19,7 @@ #ifndef CXXMPH_STRINGPIECE_H__ #define CXXMPH_STRINGPIECE_H__ +#include #include #include #include