Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
lib
container
moveLogProbVector.cc
Go to the documentation of this file.
1
#include "
osl/container/moveLogProbVector.h
"
2
#include <boost/foreach.hpp>
3
#include <algorithm>
4
#include <iostream>
5
6
// 厳密な整列は特に必要ではない
7
// #define RIGID_SORT_OF_MOVE
8
9
#ifndef MINIMAL
10
std::ostream&
osl::container::operator<<
(std::ostream& os,
MoveLogProbVector
const
& mv)
11
{
12
os<<
"LogProbVector"
<< std::endl;
13
BOOST_FOREACH(
const
MoveLogProb
& move, mv)
14
{
15
os << move << std::endl;
16
}
17
return
os << std::endl;
18
}
19
#endif
20
bool
osl::container::operator==
(
const
MoveLogProbVector
& l,
const
MoveLogProbVector
& r)
21
{
22
return
l.size() == r.size()
23
&& std::equal(l.begin(), l.end(), r.begin());
24
}
25
26
namespace
osl
27
{
28
template
<
bool
isLess>
29
struct
LogProbCompare
30
{
31
bool
operator()
(
const
MoveLogProb
& l,
const
MoveLogProb
& r)
const
32
{
33
#ifdef RIGID_SORT_OF_MOVE
34
if
(l.
logProb
() != r.
logProb
())
35
{
36
#endif
37
if
(isLess)
38
return
l.
logProb
() < r.
logProb
();
39
else
40
return
l.
logProb
() > r.
logProb
();
41
#ifdef RIGID_SORT_OF_MOVE
42
}
43
return
l.
move
() > r.
move
();
44
#endif
45
}
46
};
47
}
48
49
void
osl::container::MoveLogProbVector::sortByProbability
()
50
{
51
std::sort(begin(), end(),
LogProbCompare<true>
());
52
}
53
void
osl::container::MoveLogProbVector::sortByProbabilityReverse
()
54
{
55
std::sort(begin(), end(),
LogProbCompare<false>
());
56
}
57
58
const
osl::MoveLogProb
*
osl::container::MoveLogProbVector::find
(
Move
m)
const
59
{
60
for
(const_iterator p=begin(); p!=end(); ++p)
61
if
(p->move() == m)
62
return
&*p;
63
return
0;
64
}
65
66
// ;;; Local Variables:
67
// ;;; mode:c++
68
// ;;; c-basic-offset:2
69
// ;;; End:
Generated on Sun Jul 21 2013 13:37:25 by
1.8.4