/usr/include/osl/ntesuki/ntesukiTable.tcc is in libosl-dev 0.8.0-1.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | /* ntesukiTable.tcc
*/
#include "osl/ntesuki/ntesukiTable.h"
#include "osl/ntesuki/ntesukiMoveGenerator.h"
#include "osl/apply_move/applyMoveWithPath.h"
#include <iterator>
using namespace osl;
using namespace osl::ntesuki;
template<class Search, class F> class
DoUndoMoveHelper
{
Search* searcher;
F& func;
NumEffectState& state;
NtesukiRecord *child;
public:
DoUndoMoveHelper(Search* searcher,
F& func,
NumEffectState& state,
NtesukiRecord *child)
: searcher(searcher), state(state), child(child)
{
}
void operator()(Square last_to)
{
(*searcher).template forEachRecordFrom<F>(func, state, child);
}
};
template <class F>
void
osl::ntesuki::NtesukiTable::Table::
forEachRecord(F& func)
{
for (iterator it = begin(); it != end(); ++it)
{
for (NtesukiRecord::RecordList::iterator p = it->second.begin();
p != it->second.end(); ++p)
{
NtesukiRecord *r = &(*p);
func(r);
}
}
}
template <class F>
void
osl::ntesuki::NtesukiTable::Table::
forEachRecordFrom(F& func,
NumEffectState& state,
NtesukiRecord *record)
{
NtesukiMoveGenerator mg;
NtesukiMoveList all_moves;
mg.generateSlow(state.turn(), state, all_moves);
func.enter(record);
std::vector<NtesukiMove> moves;
std::copy(all_moves.begin(), all_moves.end(),
std::back_insert_iterator<std::vector<NtesukiMove> >(moves));
typename F::Compare c;
std::sort(moves.begin(), moves.end(), c);
for (std::vector<NtesukiMove>::const_iterator it = moves.begin();
it != moves.end(); ++it)
{
const NtesukiMove& m = *it;
NtesukiRecord *child = find(record->key.newHashWithMove(m.getMove()));
if (child)
{
if (func.withChildMove(m, child))
{
DoUndoMoveHelper<Table, F> helper(func, state, child);
ApplyMoveOfTurn::doUndoMove(state, m.getMove(), helper);
}
}
else
{
func.noChildMove(m);
}
}
func.exit();
}
template <class F>
void
osl::ntesuki::NtesukiTable::Table::
forEachRecordFromRoot(F& func)
{
if (rootState.get() == NULL)
{
throw RootStateNotSet();
}
NumEffectState state(*rootState);
forEachRecordFrom<F>(func, state, root);
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|