mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
add Bitmaps class to store cache possible bitmaps
This commit is contained in:
parent
55698d15bc
commit
063387bbe0
@ -0,0 +1,26 @@
|
||||
#include "Bitmaps.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
Bitmaps::~Bitmaps()
|
||||
{
|
||||
RemoveAllInColl(m_coll);
|
||||
}
|
||||
|
||||
const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm)
|
||||
{
|
||||
Coll::const_iterator iter = m_coll.find(&bm);
|
||||
if (iter == m_coll.end()) {
|
||||
WordsBitmap *newBM = new WordsBitmap(bm);
|
||||
m_coll.insert(newBM);
|
||||
return *newBM;
|
||||
}
|
||||
else {
|
||||
return **iter;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,11 +4,18 @@
|
||||
#include "WordsBitmap.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
class Bitmaps
|
||||
{
|
||||
typedef boost::unordered_set<WordsBitmap*, UnorderedComparer<WordsBitmap>, UnorderedComparer<WordsBitmap> > Coll;
|
||||
typedef boost::unordered_set<const WordsBitmap*, UnorderedComparer<WordsBitmap>, UnorderedComparer<WordsBitmap> > Coll;
|
||||
Coll m_coll;
|
||||
|
||||
public:
|
||||
const WordsBitmap &GetBitmap();
|
||||
virtual ~Bitmaps();
|
||||
const WordsBitmap &GetBitmap(const WordsBitmap &bm);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user