This commit is contained in:
Hieu Hoang 2015-10-26 12:03:54 +00:00
parent 20e3827ed2
commit 692d4c3f32
3 changed files with 23 additions and 25 deletions

View File

@ -48,8 +48,8 @@ Bitmap::Bitmap(size_t size, const std::vector<bool>& initializer)
//! Create Bitmap of length size and initialise.
Bitmap::Bitmap(size_t size)
:m_bitmap(size, false)
,m_firstGap(0)
,m_numWordsCovered(0)
,m_firstGap(0)
,m_numWordsCovered(0)
{
}
@ -63,11 +63,11 @@ Bitmap::Bitmap(const Bitmap &copy)
}
Bitmap::Bitmap(const Bitmap &copy, const Range &range)
:m_bitmap(copy.m_bitmap)
,m_firstGap(copy.m_firstGap)
,m_numWordsCovered(copy.m_numWordsCovered)
:m_bitmap(copy.m_bitmap)
,m_firstGap(copy.m_firstGap)
,m_numWordsCovered(copy.m_numWordsCovered)
{
SetValueNonOverlap(range);
SetValueNonOverlap(range);
}
// for unordered_set in stack

View File

@ -83,15 +83,15 @@ private:
//! set value between 2 positions, inclusive
void
SetValueNonOverlap(Range const& range) {
size_t startPos = range.GetStartPos();
size_t endPos = range.GetEndPos();
size_t startPos = range.GetStartPos();
size_t endPos = range.GetEndPos();
for(size_t pos = startPos ; pos <= endPos ; pos++) {
m_bitmap[pos] = true;
}
for(size_t pos = startPos ; pos <= endPos ; pos++) {
m_bitmap[pos] = true;
}
m_numWordsCovered += range.GetNumWordsCovered();
UpdateFirstGap(startPos, endPos, true);
m_numWordsCovered += range.GetNumWordsCovered();
UpdateFirstGap(startPos, endPos, true);
}
public:
@ -148,17 +148,15 @@ public:
void SetValue( size_t pos, bool value ) {
bool origValue = m_bitmap[pos];
if (origValue == value) {
// do nothing
}
else {
m_bitmap[pos] = value;
UpdateFirstGap(pos, pos, value);
if (value) {
++m_numWordsCovered;
}
else {
--m_numWordsCovered;
}
// do nothing
} else {
m_bitmap[pos] = value;
UpdateFirstGap(pos, pos, value);
if (value) {
++m_numWordsCovered;
} else {
--m_numWordsCovered;
}
}
}

View File

@ -428,7 +428,7 @@ inline float CalcTranslationScore(const std::vector<float> &probVector,
out << *this; \
return out.str(); \
} \
//! delete and remove every element of a collection object such as set, list etc
template<class COLL>
void RemoveAllInColl(COLL &coll)