1 | // $Id: DataWeight.cc 1379 2008-07-16 21:41:58Z peter $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2008 Peter Johansson |
---|
5 | |
---|
6 | This file is part of the yat library, http://trac.thep.lu.se/yat |
---|
7 | |
---|
8 | The yat library is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License as |
---|
10 | published by the Free Software Foundation; either version 2 of the |
---|
11 | License, or (at your option) any later version. |
---|
12 | |
---|
13 | The yat library is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
21 | 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include "DataWeight.h" |
---|
25 | |
---|
26 | #include <cassert> |
---|
27 | |
---|
28 | namespace theplu { |
---|
29 | namespace yat { |
---|
30 | namespace utility { |
---|
31 | |
---|
32 | DataWeight::DataWeight(double data, double weight) |
---|
33 | : data_(data), weight_(weight) {} |
---|
34 | |
---|
35 | |
---|
36 | double& DataWeight::data(void) |
---|
37 | { |
---|
38 | return data_; |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | const double& DataWeight::data(void) const |
---|
43 | { |
---|
44 | return data_; |
---|
45 | } |
---|
46 | |
---|
47 | double& DataWeight::weight(void) |
---|
48 | { |
---|
49 | return weight_; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | const double& DataWeight::weight(void) const |
---|
54 | { |
---|
55 | return weight_; |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | bool operator==(const DataWeight& lhs, const DataWeight& rhs) |
---|
60 | { |
---|
61 | return lhs.data() == rhs.data(); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | bool operator!=(const DataWeight& lhs, const DataWeight& rhs) |
---|
66 | { |
---|
67 | return ! (lhs == rhs); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | bool operator<(const DataWeight& lhs, const DataWeight& rhs) |
---|
72 | { |
---|
73 | return lhs.data() < rhs.data(); |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | bool operator>(const DataWeight& lhs, const DataWeight& rhs) |
---|
78 | { |
---|
79 | return rhs < lhs; |
---|
80 | } |
---|
81 | |
---|
82 | |
---|
83 | bool operator<=(const DataWeight& lhs, const DataWeight& rhs) |
---|
84 | { |
---|
85 | return rhs > lhs; |
---|
86 | } |
---|
87 | |
---|
88 | |
---|
89 | bool operator>=(const DataWeight& lhs, const DataWeight& rhs) |
---|
90 | { |
---|
91 | return rhs < lhs; |
---|
92 | } |
---|
93 | |
---|
94 | |
---|
95 | }}} // of namespace utility, yat, and theplu |
---|