diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-09-13 13:25:46 +0100 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-09-13 13:25:46 +0100 |
commit | 38a5bee71f6b49515cd105a9467ff602ff9dee64 (patch) | |
tree | 9e17da6cf072beb0150d82fee1d8e4756c8f0253 /utils/perfect_hash.h | |
parent | b09ca8a5e6f5e8c1840e51a93c9f8e6b8c4bcc33 (diff) |
optional support for doing perfect hashing of feature strings to save lots of memory
Diffstat (limited to 'utils/perfect_hash.h')
-rw-r--r-- | utils/perfect_hash.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/utils/perfect_hash.h b/utils/perfect_hash.h new file mode 100644 index 00000000..8ac11f18 --- /dev/null +++ b/utils/perfect_hash.h @@ -0,0 +1,24 @@ +#ifndef _PERFECT_HASH_MAP_H_ +#define _PERFECT_HASH_MAP_H_ + +#include "config.h" + +#ifndef HAVE_CMPH +#error libcmph is required to use PerfectHashFunction +#endif + +#include <vector> +#include <boost/utility.hpp> +#include "cmph.h" + +class PerfectHashFunction : boost::noncopyable { + public: + explicit PerfectHashFunction(const std::string& fname); + ~PerfectHashFunction(); + size_t operator()(const std::string& key) const; + size_t number_of_keys() const; + private: + cmph_t *mphf_; +}; + +#endif |