diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-19 15:49:08 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-19 15:49:08 +0300 |
commit | db24036313717458c6995e087b1db1379867aab8 (patch) | |
tree | 15508ad2be39d354fe22430bbb85b78d1bc6f81b /moses/Bitmaps.cpp | |
parent | b9f216cc96fda35fad9983037f02100e611c55fc (diff) |
share bitmaps
Diffstat (limited to 'moses/Bitmaps.cpp')
-rw-r--r-- | moses/Bitmaps.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/moses/Bitmaps.cpp b/moses/Bitmaps.cpp index f4c78f914..2637cd46d 100644 --- a/moses/Bitmaps.cpp +++ b/moses/Bitmaps.cpp @@ -4,6 +4,12 @@ namespace Moses { +Bitmaps::Bitmaps(size_t inputSize) +{ + m_initBitmap = new WordsBitmap(inputSize); + m_coll.insert(m_initBitmap); +} + Bitmaps::~Bitmaps() { RemoveAllInColl(m_coll); @@ -13,10 +19,25 @@ 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); + WordsBitmap *newBM = new WordsBitmap(bm); + m_coll.insert(newBM); + return *newBM; + } else { + return **iter; + } +} + +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; } } |