This commit is contained in:
Hieu Hoang 2015-12-29 09:11:01 -05:00
parent dea29e1b5b
commit eb5bb41900
2 changed files with 9 additions and 7 deletions

View File

@ -82,12 +82,14 @@ void MiniStack::SortAndPruneHypos(const Manager &mgr) const
///////////////////////////////////////////////////////////////
Stack::Stack(const Manager &mgr)
:m_alloc(mgr.GetPool())
,m_coll(m_alloc)
{
MemPool &pool = mgr.GetPool();
m_coll = new (pool.Allocate<Coll>()) Coll(m_alloc);
}
Stack::~Stack()
{
//delete m_coll;
}
void Stack::Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle)
@ -137,7 +139,7 @@ StackAdd Stack::Add(const Hypothesis *hypo)
std::vector<const Hypothesis*> Stack::GetBestHypos(size_t num) const
{
std::vector<const Hypothesis*> ret;
BOOST_FOREACH(const Coll::value_type &val, m_coll) {
BOOST_FOREACH(const Coll::value_type &val, *m_coll) {
const MiniStack::_HCType &hypos = val.second.GetColl();
ret.insert(ret.end(), hypos.begin(), hypos.end());
}
@ -156,7 +158,7 @@ std::vector<const Hypothesis*> Stack::GetBestHypos(size_t num) const
size_t Stack::GetHypoSize() const
{
size_t ret = 0;
BOOST_FOREACH(const Coll::value_type &val, m_coll) {
BOOST_FOREACH(const Coll::value_type &val, *m_coll) {
const MiniStack::_HCType &hypos = val.second.GetColl();
ret += hypos.size();
}
@ -177,7 +179,7 @@ MiniStack &Stack::GetMiniStack(const HypoCoverage &key)
}
return *ret;
*/
return m_coll[key];
return (*m_coll)[key];
}
}

View File

@ -73,19 +73,19 @@ public:
size_t GetHypoSize() const;
Coll &GetColl()
{ return m_coll; }
{ return *m_coll; }
void Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle);
std::vector<const Hypothesis*> GetBestHypos(size_t num) const;
void Clear()
{
m_coll.clear();
m_coll->clear();
}
protected:
MemPoolAllocator< std::pair<HypoCoverage const, MiniStack> > m_alloc;
Coll m_coll;
Coll *m_coll;
StackAdd Add(const Hypothesis *hypo);