mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-05 02:22:21 +03:00
mempool
This commit is contained in:
parent
dea29e1b5b
commit
eb5bb41900
@ -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];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user