mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-05 02:22:21 +03:00
delete Stacks class
This commit is contained in:
parent
d8f65ecbc9
commit
f66885166e
@ -55,7 +55,6 @@ external-lib boost_serialization ;
|
||||
Search/CubePruning/Misc.cpp
|
||||
Search/CubePruning/Search.cpp
|
||||
Search/CubePruning/Stack.cpp
|
||||
Search/CubePruning/Stacks.cpp
|
||||
legacy/Bitmap.cpp
|
||||
legacy/Bitmaps.cpp
|
||||
legacy/Factor.cpp
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <boost/pool/pool_alloc.hpp>
|
||||
#include "../Search.h"
|
||||
#include "Misc.h"
|
||||
#include "Stacks.h"
|
||||
#include "Stack.h"
|
||||
#include "../../legacy/Range.h"
|
||||
|
||||
namespace Moses2
|
||||
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Stacks.cpp
|
||||
*
|
||||
* Created on: 6 Nov 2015
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#include "Stacks.h"
|
||||
#include "../../System.h"
|
||||
#include "../Manager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
|
||||
namespace NSCubePruning
|
||||
{
|
||||
|
||||
Stacks::Stacks(const Manager &mgr)
|
||||
:m_mgr(mgr)
|
||||
{
|
||||
}
|
||||
|
||||
Stacks::~Stacks()
|
||||
{
|
||||
}
|
||||
|
||||
void Stacks::Init(size_t numStacks)
|
||||
{
|
||||
m_stacks.resize(numStacks, NULL);
|
||||
}
|
||||
|
||||
void Stacks::ReadyToDecode(size_t ind)
|
||||
{
|
||||
if (ind) {
|
||||
// reuse previous stack
|
||||
Stack *stack = m_stacks[ind - 1];
|
||||
stack->Clear();
|
||||
|
||||
m_stacks[ind - 1] = NULL;
|
||||
m_stacks[ind] = stack;
|
||||
}
|
||||
else {
|
||||
m_stacks[ind] = new (m_mgr.GetPool().Allocate<Stack>()) Stack(m_mgr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream &out, const Stacks &obj)
|
||||
{
|
||||
for (size_t i = 0; i < obj.GetSize(); ++i) {
|
||||
const Stack *stack = obj.m_stacks[i];
|
||||
if (stack) {
|
||||
out << stack->GetHypoSize() << " ";
|
||||
}
|
||||
else {
|
||||
out << "N ";
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void Stacks::Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle)
|
||||
{
|
||||
size_t numWordsCovered = hypo->GetBitmap().GetNumWordsCovered();
|
||||
//cerr << "numWordsCovered=" << numWordsCovered << endl;
|
||||
Stack &stack = *m_stacks[numWordsCovered];
|
||||
stack.Add(hypo, hypoRecycle);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Stacks.h
|
||||
*
|
||||
* Created on: 6 Nov 2015
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "Stack.h"
|
||||
#include "../../Recycler.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
class Manager;
|
||||
|
||||
namespace NSCubePruning
|
||||
{
|
||||
|
||||
class Stacks {
|
||||
friend std::ostream& operator<<(std::ostream &, const Stacks &);
|
||||
public:
|
||||
Stacks(const Manager &mgr);
|
||||
virtual ~Stacks();
|
||||
|
||||
void Init(size_t numStacks);
|
||||
void ReadyToDecode(size_t ind);
|
||||
|
||||
size_t GetSize() const
|
||||
{ return m_stacks.size(); }
|
||||
|
||||
const Stack &Back() const
|
||||
{ return *m_stacks.back(); }
|
||||
|
||||
Stack &operator[](size_t ind)
|
||||
{ return *m_stacks[ind]; }
|
||||
|
||||
void Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle);
|
||||
|
||||
protected:
|
||||
const Manager &m_mgr;
|
||||
std::vector<Stack*> m_stacks;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user