moveLogProbVector.cc
Go to the documentation of this file.
#include "osl/container/moveLogProbVector.h"
#include <algorithm>
#include <iostream>
// 厳密な整列は特に必要ではない
// #define RIGID_SORT_OF_MOVE
#ifndef MINIMAL
std::ostream& osl::container::operator<<(std::ostream& os,MoveLogProbVector const& mv)
{
os<< "LogProbVector" << std::endl;
for (const MoveLogProb& move: mv)
{
os << move << std::endl;
}
return os << std::endl;
}
#endif
bool osl::container::operator==(const MoveLogProbVector& l, const MoveLogProbVector& r)
{
return l.size() == r.size()
&& std::equal(l.begin(), l.end(), r.begin());
}
namespace osl
{
template <bool isLess>
struct LogProbCompare
{
bool operator()(const MoveLogProb& l, const MoveLogProb& r) const
{
#ifdef RIGID_SORT_OF_MOVE
if (l.logProb() != r.logProb())
{
#endif
if (isLess)
return l.logProb() < r.logProb();
else
return l.logProb() > r.logProb();
#ifdef RIGID_SORT_OF_MOVE
}
return l.move() > r.move();
#endif
}
};
}
void osl::container::MoveLogProbVector::sortByProbability()
{
std::sort(begin(), end(), LogProbCompare<true>());
}
void osl::container::MoveLogProbVector::sortByProbabilityReverse()
{
std::sort(begin(), end(), LogProbCompare<false>());
}
const osl::MoveLogProb* osl::container::MoveLogProbVector::find(Move m) const
{
for (const_iterator p=begin(); p!=end(); ++p)
if (p->move() == m)
return &*p;
return 0;
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::FixedCapacityVector::size
size_t size() const
Definition container.h:243
osl::FixedCapacityVector::end
iterator end()
Definition container.h:199
osl::FixedCapacityVector::begin
iterator begin()
Definition container.h:198
osl::FixedCapacityVector< MoveLogProb, Move::MaxUniqMoves >::const_iterator
array_t::const_iterator const_iterator
Definition container.h:157
osl::MoveLogProb
Definition moveLogProb.h:10
osl::MoveLogProb::logProb
int logProb() const
Definition moveLogProb.h:40
osl::MoveLogProb::move
const Move move() const
Definition moveLogProb.h:39
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::container::MoveLogProbVector
Definition moveLogProbVector.h:14
osl::container::MoveLogProbVector::sortByProbabilityReverse
void sortByProbabilityReverse()
確率が低い順にsort
Definition moveLogProbVector.cc:52
osl::container::MoveLogProbVector::find
const MoveLogProb * find(Move) const
Definition moveLogProbVector.cc:57
osl::container::MoveLogProbVector::sortByProbability
void sortByProbability()
確率が高い順にsort
Definition moveLogProbVector.cc:48
moveLogProbVector.h
osl::container::operator==
bool operator==(BitXmask l, BitXmask r)
Definition bitXmask.h:33
osl::container::operator<<
std::ostream & operator<<(std::ostream &, const BitXmask)
Definition bitXmask.cc:6
osl
Definition additionalEffect.h:6
osl::LogProbCompare
Definition moveLogProbVector.cc:29
osl::LogProbCompare::operator()
bool operator()(const MoveLogProb &l, const MoveLogProb &r) const
Definition moveLogProbVector.cc:30