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