blob: db527b39f9060b3fb620d9e7ae29aef8bea7829f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* Cube.h
* moses-chart
*
* Created by Hieu Hoang on 18/08/2009.
* Copyright 2009 __MyCompanyName__. All rights reserved.
*
*/
#include <queue>
#include <vector>
#include <set>
#include "QueueEntry.h"
namespace MosesChart
{
class QueueEntryUniqueOrderer
{
public:
bool operator()(const QueueEntry* entryA, const QueueEntry* entryB) const
{
return (*entryA) < (*entryB);
}
};
class QueueEntryScoreOrderer
{
public:
bool operator()(const QueueEntry* entryA, const QueueEntry* entryB) const
{
return (entryA->GetCombinedScore() < entryB->GetCombinedScore());
}
};
class Cube
{
protected:
typedef std::set<QueueEntry*, QueueEntryUniqueOrderer> UniqueCubeEntry;
UniqueCubeEntry m_uniqueEntry;
typedef std::priority_queue<QueueEntry*, std::vector<QueueEntry*>, QueueEntryScoreOrderer> SortedByScore;
SortedByScore m_sortedByScore;
public:
~Cube();
bool IsEmpty() const
{ return m_sortedByScore.empty(); }
QueueEntry *Pop();
bool Add(QueueEntry *queueEntry);
};
};
|