mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
use mempool for vector
This commit is contained in:
parent
637def281c
commit
d4dd0c0a28
@ -11,9 +11,12 @@
|
||||
|
||||
namespace Moses2 {
|
||||
|
||||
HReorderingBackwardState::HReorderingBackwardState(const LRModel &config,
|
||||
HReorderingBackwardState::HReorderingBackwardState(
|
||||
MemPool &pool,
|
||||
const LRModel &config,
|
||||
size_t offset)
|
||||
:LRState(config, LRModel::Backward, offset)
|
||||
,reoStack(pool)
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
|
@ -16,7 +16,9 @@ private:
|
||||
ReorderingStack reoStack;
|
||||
|
||||
public:
|
||||
HReorderingBackwardState(const LRModel &config,
|
||||
HReorderingBackwardState(
|
||||
MemPool &pool,
|
||||
const LRModel &config,
|
||||
size_t offset);
|
||||
|
||||
virtual void Init(const LRState *prev,
|
||||
|
@ -171,7 +171,7 @@ LRState *LRModel::CreateLRState(MemPool &pool) const
|
||||
//cerr << "bwd=" << bwd << bwd->ToString() << endl;
|
||||
}
|
||||
else {
|
||||
bwd = new (pool.Allocate<HReorderingBackwardState>()) HReorderingBackwardState(*this, offset);
|
||||
bwd = new (pool.Allocate<HReorderingBackwardState>()) HReorderingBackwardState(pool, *this, offset);
|
||||
}
|
||||
offset += m_collapseScores ? 1 : GetNumberOfTypes();
|
||||
if (m_direction == Backward) return bwd; // else fall through
|
||||
|
@ -4,11 +4,18 @@
|
||||
** Date: Jan 26, 2010
|
||||
*/
|
||||
|
||||
#include "ReorderingStack.h"
|
||||
#include <vector>
|
||||
#include "ReorderingStack.h"
|
||||
#include "../../MemPool.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
ReorderingStack::ReorderingStack(MemPool &pool)
|
||||
:m_stack(pool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReorderingStack::Init()
|
||||
{
|
||||
m_stack.clear();
|
||||
|
@ -13,19 +13,20 @@
|
||||
//#include "TypeDef.h"
|
||||
//#include "Util.h"
|
||||
#include "../../legacy/Range.h"
|
||||
#include "../../Vector.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
class MemPool;
|
||||
|
||||
/** @todo what is this?
|
||||
*/
|
||||
class ReorderingStack
|
||||
{
|
||||
private:
|
||||
|
||||
std::vector<Range> m_stack;
|
||||
Vector<Range> m_stack;
|
||||
|
||||
public:
|
||||
ReorderingStack(MemPool &pool);
|
||||
|
||||
size_t hash() const;
|
||||
bool operator==(const ReorderingStack& other) const;
|
||||
|
@ -14,13 +14,13 @@ namespace Moses2
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class Vector : public std::vector<T>
|
||||
class Vector : public std::vector<T, MemPoolAllocator<T> >
|
||||
{
|
||||
typedef std::vector<T> Parent;
|
||||
typedef std::vector<T, MemPoolAllocator<T> > Parent;
|
||||
|
||||
public:
|
||||
Vector(MemPool &pool, size_t size = 0, const T &val = T())
|
||||
:Parent(size, val)
|
||||
:Parent(size, val, MemPoolAllocator<T>(pool) )
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user