00001 #include "osl/container/pieceVector.h" 00002 #include "osl/eval/pieceEval.h" 00003 #include <boost/foreach.hpp> 00004 #include <algorithm> 00005 #include <iostream> 00006 00007 namespace osl 00008 { 00009 struct PieceBasicLessThan 00010 { 00011 bool operator()(Piece p0,Piece p1){ 00012 const Ptype ptype0=unpromote(p0.ptype()); 00013 const Ptype ptype1=unpromote(p1.ptype()); 00014 return (eval::Ptype_Eval_Table.value(ptype0) 00015 < eval::Ptype_Eval_Table.value(ptype1)); 00016 } 00017 }; 00018 struct PiecePtypeMoreThan 00019 { 00020 bool operator()(Piece p0,Piece p1){ 00021 const PtypeO ptypeo0=p0.ptypeO(); 00022 const PtypeO ptypeo1=p1.ptypeO(); 00023 return (abs(eval::Ptype_Eval_Table.captureValue(ptypeo0)) 00024 > abs(eval::Ptype_Eval_Table.captureValue(ptypeo1))); 00025 } 00026 }; 00027 } // namespace osl 00028 00029 void osl::container::PieceVector::sortByBasic() 00030 { 00031 std::sort(begin(),end(),PieceBasicLessThan()); 00032 } 00033 00034 void osl::container::PieceVector::sortByPtype() 00035 { 00036 std::sort(begin(),end(),PiecePtypeMoreThan()); 00037 } 00038 00039 #ifndef MINIMAL 00040 std::ostream& osl::container::operator<<(std::ostream& os,PieceVector const& pv) 00041 { 00042 os << "PieceVector"; 00043 BOOST_FOREACH(Piece p, pv) { 00044 os << " " << p; 00045 } 00046 return os << std::endl; 00047 } 00048 #endif 00049 // ;;; Local Variables: 00050 // ;;; mode:c++ 00051 // ;;; c-basic-offset:2 00052 // ;;; End: