File: pieceVector.cc

package info (click to toggle)
libosl 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 273,976 kB
  • sloc: cpp: 129,625; ansic: 7,145; ruby: 1,290; makefile: 558; perl: 413; sh: 35
file content (52 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download | duplicates (3)
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
#include "osl/container/pieceVector.h"
#include "osl/eval/pieceEval.h"
#include <boost/foreach.hpp>
#include <algorithm>
#include <iostream>

namespace osl
{
  struct PieceBasicLessThan
  {
    bool operator()(Piece p0,Piece p1){
      const Ptype ptype0=unpromote(p0.ptype());
      const Ptype ptype1=unpromote(p1.ptype());
      return (eval::Ptype_Eval_Table.value(ptype0)
	      < eval::Ptype_Eval_Table.value(ptype1));
    }
  };
  struct PiecePtypeMoreThan
  {
    bool operator()(Piece p0,Piece p1){
      const PtypeO ptypeo0=p0.ptypeO();
      const PtypeO ptypeo1=p1.ptypeO();
      return (abs(eval::Ptype_Eval_Table.captureValue(ptypeo0))
	      > abs(eval::Ptype_Eval_Table.captureValue(ptypeo1)));
    }
  };
} // namespace osl

void osl::container::PieceVector::sortByBasic()
{
  std::sort(begin(),end(),PieceBasicLessThan());
}

void osl::container::PieceVector::sortByPtype()
{
  std::sort(begin(),end(),PiecePtypeMoreThan());
}

#ifndef MINIMAL
std::ostream& osl::container::operator<<(std::ostream& os,PieceVector const& pv)
{
  os << "PieceVector";
  BOOST_FOREACH(Piece p, pv) {
    os << " " << p;
  }
  return os << std::endl;
}
#endif
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End: