#include #include #include #include #include "mph_index.h" using std::string; using std::vector; using namespace cxxmph; int main(int argc, char** argv) { srand(1); vector keys; keys.push_back("davi"); keys.push_back("paulo"); keys.push_back("joao"); keys.push_back("maria"); keys.push_back("bruno"); keys.push_back("paula"); keys.push_back("diego"); keys.push_back("diogo"); keys.push_back("algume"); SimpleMPHIndex mph_index; if (!mph_index.Reset(keys.begin(), keys.end(), keys.size())) { exit(-1); } vector ids; for (vector::size_type i = 0; i < keys.size(); ++i) { ids.push_back(mph_index.index(keys[i])); cerr << " " << *(ids.end() - 1); } cerr << endl; sort(ids.begin(), ids.end()); for (vector::size_type i = 0; i < ids.size(); ++i) assert(ids[i] == static_cast::value_type>(i)); /* char* serialized = new char[mph_index.serialize_bytes_needed()]; mph_index.serialize(serialized); SimpleMPHIndex other_mph_index; other_mph_index.deserialize(serialized); */ }