summaryrefslogtreecommitdiff
path: root/utils/best.h
blob: ed15e0be9ce2b136fc9f0d94369acde81f3d4bcd (plain)
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
#ifndef UTILS__BEST_H
#define UTILS__BEST_H

#include "max_plus.h"

typedef MaxPlus<double> best_t;

inline bool better(best_t const& a,best_t const& b) {
  return a.v_>b.v_; // intentionally reversed, so default min-heap, sort, etc. put best first.
}

inline bool operator <(best_t const& a,best_t const& b) {
  return a.v_>b.v_; // intentionally reversed, so default min-heap, sort, etc. put best first.
}
struct BetterP {
  inline bool operator ()(best_t const& a,best_t const& b) const {
    return a.v_>b.v_; // intentionally reversed, so default min-heap, sort, etc. put best first.
  }
};

inline void maybe_improve(best_t &a,best_t const& b) {
  if (a.v_>b.v_)
    a.v_=b.v_;
}

template <class O>
inline void maybe_improve(best_t &a,O const& b) {
  if (a.v_>b.v_)
    a.v_=b.v_;
}

#endif