1379 |
16 Jul 08 |
peter |
// $Id$ |
1379 |
16 Jul 08 |
peter |
2 |
|
1379 |
16 Jul 08 |
peter |
3 |
/* |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2009, 2012 Peter Johansson |
1379 |
16 Jul 08 |
peter |
6 |
|
1469 |
02 Sep 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
1379 |
16 Jul 08 |
peter |
8 |
|
1379 |
16 Jul 08 |
peter |
The yat library is free software; you can redistribute it and/or |
1379 |
16 Jul 08 |
peter |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
1379 |
16 Jul 08 |
peter |
License, or (at your option) any later version. |
1379 |
16 Jul 08 |
peter |
13 |
|
1379 |
16 Jul 08 |
peter |
The yat library is distributed in the hope that it will be useful, |
1379 |
16 Jul 08 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1379 |
16 Jul 08 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1379 |
16 Jul 08 |
peter |
General Public License for more details. |
1379 |
16 Jul 08 |
peter |
18 |
|
1379 |
16 Jul 08 |
peter |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
1379 |
16 Jul 08 |
peter |
21 |
*/ |
1379 |
16 Jul 08 |
peter |
22 |
|
2881 |
18 Nov 12 |
peter |
23 |
#include <config.h> |
2881 |
18 Nov 12 |
peter |
24 |
|
1379 |
16 Jul 08 |
peter |
25 |
#include "DataWeight.h" |
2003 |
13 Jun 09 |
peter |
26 |
#include "stl_utility.h" |
1379 |
16 Jul 08 |
peter |
27 |
|
1379 |
16 Jul 08 |
peter |
28 |
namespace theplu { |
1379 |
16 Jul 08 |
peter |
29 |
namespace yat { |
4200 |
19 Aug 22 |
peter |
30 |
namespace utility { |
1379 |
16 Jul 08 |
peter |
31 |
|
1379 |
16 Jul 08 |
peter |
32 |
DataWeight::DataWeight(double data, double weight) |
1379 |
16 Jul 08 |
peter |
33 |
: data_(data), weight_(weight) {} |
1379 |
16 Jul 08 |
peter |
34 |
|
1379 |
16 Jul 08 |
peter |
35 |
|
1379 |
16 Jul 08 |
peter |
36 |
double& DataWeight::data(void) |
1379 |
16 Jul 08 |
peter |
37 |
{ |
1379 |
16 Jul 08 |
peter |
38 |
return data_; |
1379 |
16 Jul 08 |
peter |
39 |
} |
1379 |
16 Jul 08 |
peter |
40 |
|
1379 |
16 Jul 08 |
peter |
41 |
|
1379 |
16 Jul 08 |
peter |
42 |
const double& DataWeight::data(void) const |
1379 |
16 Jul 08 |
peter |
43 |
{ |
1379 |
16 Jul 08 |
peter |
44 |
return data_; |
1379 |
16 Jul 08 |
peter |
45 |
} |
1379 |
16 Jul 08 |
peter |
46 |
|
1379 |
16 Jul 08 |
peter |
47 |
double& DataWeight::weight(void) |
1379 |
16 Jul 08 |
peter |
48 |
{ |
1379 |
16 Jul 08 |
peter |
49 |
return weight_; |
1379 |
16 Jul 08 |
peter |
50 |
} |
1379 |
16 Jul 08 |
peter |
51 |
|
1379 |
16 Jul 08 |
peter |
52 |
|
1379 |
16 Jul 08 |
peter |
53 |
const double& DataWeight::weight(void) const |
1379 |
16 Jul 08 |
peter |
54 |
{ |
1379 |
16 Jul 08 |
peter |
55 |
return weight_; |
1379 |
16 Jul 08 |
peter |
56 |
} |
1379 |
16 Jul 08 |
peter |
57 |
|
1379 |
16 Jul 08 |
peter |
58 |
|
1379 |
16 Jul 08 |
peter |
59 |
bool operator==(const DataWeight& lhs, const DataWeight& rhs) |
1379 |
16 Jul 08 |
peter |
60 |
{ |
1379 |
16 Jul 08 |
peter |
61 |
return lhs.data() == rhs.data(); |
1379 |
16 Jul 08 |
peter |
62 |
} |
1379 |
16 Jul 08 |
peter |
63 |
|
1379 |
16 Jul 08 |
peter |
64 |
|
1379 |
16 Jul 08 |
peter |
65 |
bool operator!=(const DataWeight& lhs, const DataWeight& rhs) |
1379 |
16 Jul 08 |
peter |
66 |
{ |
1734 |
16 Jan 09 |
peter |
67 |
return lhs.data() != rhs.data(); |
1379 |
16 Jul 08 |
peter |
68 |
} |
1379 |
16 Jul 08 |
peter |
69 |
|
1379 |
16 Jul 08 |
peter |
70 |
|
1379 |
16 Jul 08 |
peter |
71 |
bool operator<(const DataWeight& lhs, const DataWeight& rhs) |
1379 |
16 Jul 08 |
peter |
72 |
{ |
2003 |
13 Jun 09 |
peter |
73 |
less_nan<DataWeight> comp; |
2003 |
13 Jun 09 |
peter |
74 |
return comp(lhs, rhs); |
1379 |
16 Jul 08 |
peter |
75 |
} |
1379 |
16 Jul 08 |
peter |
76 |
|
1379 |
16 Jul 08 |
peter |
77 |
|
1379 |
16 Jul 08 |
peter |
78 |
bool operator>(const DataWeight& lhs, const DataWeight& rhs) |
1379 |
16 Jul 08 |
peter |
79 |
{ |
2003 |
13 Jun 09 |
peter |
80 |
return rhs < lhs; |
1379 |
16 Jul 08 |
peter |
81 |
} |
1379 |
16 Jul 08 |
peter |
82 |
|
1379 |
16 Jul 08 |
peter |
83 |
|
1379 |
16 Jul 08 |
peter |
84 |
bool operator<=(const DataWeight& lhs, const DataWeight& rhs) |
1379 |
16 Jul 08 |
peter |
85 |
{ |
2003 |
13 Jun 09 |
peter |
86 |
return lhs < rhs || lhs == rhs; |
1379 |
16 Jul 08 |
peter |
87 |
} |
1379 |
16 Jul 08 |
peter |
88 |
|
1379 |
16 Jul 08 |
peter |
89 |
|
1379 |
16 Jul 08 |
peter |
90 |
bool operator>=(const DataWeight& lhs, const DataWeight& rhs) |
1379 |
16 Jul 08 |
peter |
91 |
{ |
2003 |
13 Jun 09 |
peter |
92 |
return lhs > rhs || lhs == rhs; |
1379 |
16 Jul 08 |
peter |
93 |
} |
1379 |
16 Jul 08 |
peter |
94 |
|
1379 |
16 Jul 08 |
peter |
95 |
|
1379 |
16 Jul 08 |
peter |
96 |
}}} // of namespace utility, yat, and theplu |