1
Fork 0

make install works.

This commit is contained in:
davi 2010-11-05 04:48:53 -02:00
parent 8663285897
commit c09df518dc
6 changed files with 5 additions and 93 deletions

View File

@ -1,8 +1,8 @@
bin_PROGRAMS = cmph_hash_map_test mphtable_test trigraph_test bin_PROGRAMS = cmph_hash_map_test mphtable_test trigraph_test
lib_LTLIBRARIES = libcxxmph.la lib_LTLIBRARIES = libcxxmph.la
include_HEADERS = cmph_hash_map.h mphtable.h MurmurHash2.h trigraph.h cmph_hash_function.h include_HEADERS = cmph_hash_map.h mphtable.h MurmurHash2.h trigraph.h cmph_hash_function.h stringpiece.h
libcxxmph_la_SOURCES = MurmurHash2.h trigragh.h trigraph.cc mphtable.h mphtable.cc cmph_hash_function.h libcxxmph_la_SOURCES = MurmurHash2.h trigragh.h trigraph.cc mphtable.h mphtable.cc cmph_hash_function.h stringpiece.h
libcxxmph_la_LDFLAGS = -version-info 0:0:0 libcxxmph_la_LDFLAGS = -version-info 0:0:0
cmph_hash_map_test_LDADD = libcxxmph.la cmph_hash_map_test_LDADD = libcxxmph.la

View File

@ -25,7 +25,7 @@ struct Murmur2StringPiece {
template <class Key> template <class Key>
cmph_uint32 operator()(const Key& k) const { cmph_uint32 operator()(const Key& k) const {
StringPiece s(k); StringPiece s(k);
return MurmurHash2(k.data(), k.length(), 1 /* seed */); return MurmurHash2(s.data(), s.length(), 1 /* seed */);
} }
}; };
@ -42,7 +42,7 @@ struct seeded_hash_function<Murmur2StringPiece> {
template <class Key> template <class Key>
cmph_uint32 operator()(const Key& k, cmph_uint32 seed) const { cmph_uint32 operator()(const Key& k, cmph_uint32 seed) const {
StringPiece s(k); StringPiece s(k);
return MurmurHash2(k.data(), k.length(), seed); return MurmurHash2(s.data(), s.length(), seed);
} }
}; };

View File

@ -4,7 +4,6 @@
#include "MurmurHash2.h" #include "MurmurHash2.h"
#include "mphtable.h" #include "mphtable.h"
#include "iterator_first.h"
namespace __gnu_cxx { namespace __gnu_cxx {
template <> struct hash<std::string> { template <> struct hash<std::string> {

View File

@ -1,43 +0,0 @@
#include "stringpiece.h"
namespace cxxmph {
template <typename iterator>
struct iterator_first : public iterator {
iterator_first(iterator it) : iterator(it) { }
const typename iterator::value_type::first_type& operator*() const {
return this->iterator::operator*().first;
}
};
template <typename iterator>
iterator_first<iterator> make_iterator_first(iterator it) {
return iterator_first<iterator>(it);
}
template <typename value> class MakeStringPiece {
public:
StringPiece operator()(const value& v) { return StringPiece(reinterpret_cast<const char*>(&v), sizeof(value)); }
};
template <> class MakeStringPiece<std::string> {
public:
StringPiece operator()(const std::string& v) { return StringPiece(v); }
};
template <> class MakeStringPiece<const char*> {
public:
StringPiece operator()(const char* v) { return StringPiece(v); }
};
template <typename iterator>
struct iterator_stringpiece : public iterator {
iterator_stringpiece(iterator it) : iterator(it) { }
StringPiece operator*() const {
return MakeStringPiece<typename iterator::value_type::first_type>()(this->iterator::operator*());
}
};
template <typename iterator>
iterator_stringpiece<iterator> make_iterator_stringpiece(iterator it) {
return iterator_stringpiece<iterator>(it);
}
} // namespace cxxmph

View File

@ -1,42 +0,0 @@
#ifndef __CXXMPH_RANDOMLY_SEEDED_HASH__
#define __CXXMPH_RANDOMLY_SEEDED_HASH__
// Helper to create randomly seeded hash functions out of existing hash
// functions that take a seed as a parameter.
#include <cstdlib>
#include "cmph_types.h"
#include "MurmurHash2.h"
#include "stringpiece.h"
namespace cxxmph {
template <class HashFun>
struct RandomlySeededHashFunction { };
class Murmur2StringPiece { };
class Murmur2Pod { };
template <>
struct RandomlySeededHashFunction<Murmur2StringPiece> {
RandomlySeededHashFunction() : seed(random()) { }
cmph_uint32 operator()(const StringPiece& key) const {
return MurmurHash2(key.data(), key.length(), seed);
}
cmph_uint32 seed;
};
template<>
struct RandomlySeededHashFunction<Murmur2Pod> {
RandomlySeededHashFunction() : seed(random()) { }
template<class Key>
cmph_uint32 operator()(const Key& key) const {
return MurmurHash2(&key, sizeof(key), seed);
}
cmph_uint32 seed;
};
} // namespace cxxmph
#endif // __CXXMPH_RANDOMLY_SEEDED_HASH__

View File

@ -172,8 +172,6 @@ inline bool operator>=(const cxxmph::StringPiece& x, const cxxmph::StringPiece&
} }
// allow StringPiece to be logged // allow StringPiece to be logged
inline std::ostream& operator<<(std::ostream& o, const cxxmph::StringPiece& piece) { extern std::ostream& operator<<(std::ostream& o, const cxxmph::StringPiece& piece);
return operator<<(o, std::string(piece.data(), piece.size()));
}
#endif // CXXMPH_STRINGPIECE_H__ #endif // CXXMPH_STRINGPIECE_H__