mosesdecoder/contrib/other-builds/moses2/Word.cpp

32 lines
561 B
C++
Raw Normal View History

2015-10-23 18:46:35 +03:00
/*
* Word.cpp
*
* Created on: 23 Oct 2015
* Author: hieu
*/
#include "Word.h"
2015-10-24 14:39:15 +03:00
#include "Util.h"
#include "util/murmur_hash.hh"
2015-10-23 18:46:35 +03:00
Word::Word() {
2015-10-24 14:39:15 +03:00
Init<Factor*>(m_factors, NUM_FACTOR, NULL);
2015-10-23 18:46:35 +03:00
}
Word::~Word() {
// TODO Auto-generated destructor stub
}
2015-10-24 14:39:15 +03:00
size_t Word::hash() const
{
uint64_t seed = 0;
size_t ret = util::MurmurHashNative(m_factors, sizeof(Factor*) * NUM_FACTOR, seed);
return ret;
}
bool Word::operator==(const Word &compare) const
{
int cmp = memcmp(m_factors, compare.m_factors, sizeof(Factor*) * NUM_FACTOR);
return cmp == 0;
}