Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2015-10-19 17:21:31 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-10-19 17:21:31 +0300
commitd28b00a1c6da6347d0c9f8a0ee4b01dff279e495 (patch)
tree32c6c9e7d2c0904d106e529e40fbfd7ba5105c2a /moses/Bitmaps.cpp
parentdb24036313717458c6995e087b1db1379867aab8 (diff)
share bitmaps
Diffstat (limited to 'moses/Bitmaps.cpp')
-rw-r--r--moses/Bitmaps.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/moses/Bitmaps.cpp b/moses/Bitmaps.cpp
index 2637cd46d..a052f1f7e 100644
--- a/moses/Bitmaps.cpp
+++ b/moses/Bitmaps.cpp
@@ -7,39 +7,46 @@ namespace Moses
Bitmaps::Bitmaps(size_t inputSize)
{
m_initBitmap = new WordsBitmap(inputSize);
- m_coll.insert(m_initBitmap);
+ m_coll[m_initBitmap];
}
Bitmaps::~Bitmaps()
{
- RemoveAllInColl(m_coll);
+ //RemoveAllInColl(m_coll);
}
-const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm)
+const WordsBitmap &Bitmaps::GetNextBitmap(const WordsBitmap &bm, const WordsRange &range)
{
- Coll::const_iterator iter = m_coll.find(&bm);
+ WordsBitmap *newBM = new WordsBitmap(bm);
+ newBM->SetValue(range, true);
+
+ Coll::const_iterator iter = m_coll.find(newBM);
if (iter == m_coll.end()) {
- WordsBitmap *newBM = new WordsBitmap(bm);
- m_coll.insert(newBM);
+ m_coll[newBM];
return *newBM;
} else {
- return **iter;
+ return *iter->first;
}
}
const WordsBitmap &Bitmaps::GetBitmap(const WordsBitmap &bm, const WordsRange &range)
{
- WordsBitmap *newBM = new WordsBitmap(bm);
- newBM->SetValue(range, true);
-
- Coll::const_iterator iter = m_coll.find(newBM);
- if (iter == m_coll.end()) {
- m_coll.insert(newBM);
- return *newBM;
- } else {
- delete newBM;
- return **iter;
+ Coll::iterator iter = m_coll.find(&bm);
+ assert(iter != m_coll.end());
+
+ const WordsBitmap *newBM;
+ NextBitmaps &next = iter->second;
+ NextBitmaps::const_iterator iterNext = next.find(range);
+ if (iterNext == next.end()) {
+ // not seen the link yet.
+ newBM = &GetNextBitmap(bm, range);
+ next[range] = newBM;
+ }
+ else {
+ // link exist
+ newBM = iterNext->second;
}
+ return *newBM;
}
}