#pragma once /* * functional.h * Picross * */ #include template class binfunc { public: virtual _TRet operator()(_TArg1 &, _TArg2 &) = 0; }; template class unfunc { public: virtual _TRet operator()(_TArg &) = 0; }; template class couple { public: couple(_TA a, _TB b) : m_a(a), m_b(b) { } bool operator<(const couple<_TA, _TB> &other) const { if (m_a==other.m_a) { return m_b couple<_TA, _TB> makecouple(_TA a, _TB b) { return couple<_TA, _TB>(a, b); } template class triplet { public: triplet(_TA a, _TB b, _TC c) : m_a(a), m_b(b), m_c(c) { } bool operator==(const triplet<_TA, _TB, _TC> &other) { return other.m_a==m_a && other.m_b==m_b && other.m_c==m_c; } private: _TA m_a; _TB m_b; _TC m_c; }; template triplet<_TA, _TB, _TC> maketrip(_TA a, _TB b, _TC c) { return triplet<_TA, _TB, _TC>(a, b, c); } template std::vector<_TList> filter(std::vector<_TList> &ls, unfunc<_TList, bool> &fn) { std::vector<_TList> lr; for (int i=0;i _TList reduce(std::vector<_TList> &ls, binfunc<_TList, _TList, _TList> &fn) { if (ls.size()==1) { return ls[0]; } _TList tmp = fn(ls[0], ls[1]); for (int i=0;i