source: trunk/yat/utility/DataWeight.h

Last change on this file was 2119, checked in by Peter, 12 years ago

converted files to utf-8. fixes #577

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1#ifndef _theplu_yat_utility_data_weight_
2#define _theplu_yat_utility_data_weight_
3
4// $Id: DataWeight.h 2119 2009-12-12 23:11:43Z peter $
5
6/*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009 Peter Johansson
9
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24*/
25
26namespace theplu {
27namespace yat {
28namespace utility {
29
30  /**
31     \brief Holds a pair of data and associated weight
32
33     The class has comparison operators (declared outside class) that
34     are designed to ignore the weights, and behaves like the
35     corresponding double operator behaves for data().
36
37     \since New in yat 0.5
38  */
39  class DataWeight
40  {
41  public:
42    /**
43       \brief Default constructor
44
45       \param data data value to hold
46       \param weight weight value to hold
47     */
48    explicit DataWeight(double data=0.0, double weight=1.0);
49
50    /**
51       \return reference to data
52     */
53    double& data(void);
54
55    /**
56       \return const reference to data
57     */
58    const double& data(void) const;
59
60    /**
61       \return reference to weight
62     */
63    double& weight(void);
64
65    /**
66       \return const reference to weight
67     */
68    const double& weight(void) const;
69  private:
70    double data_;
71    double weight_;
72    // using compiler generated copy
73    // DataWeight(const DataWeight&)
74    // DataWeight& operator=(const DataWeight&);
75  };
76
77  /**
78     \brief equality operator
79
80     \return true if lhs.data() == rhs.data()
81
82     \relates DataWeight
83   */
84  bool operator==(const DataWeight& lhs, const DataWeight& rhs);
85
86  /**
87     \brief inequality operator
88
89     \return true if lhs.data() != rhs.data()
90
91     \relates DataWeight
92   */
93  bool operator!=(const DataWeight&, const DataWeight&);
94
95  /**
96     \brief comparison operator
97
98     \return less_nan(lhs.data(), rhs.data())
99
100     \see less_nan
101
102     \relates DataWeight
103   */
104  bool operator<(const DataWeight&, const DataWeight&);
105
106  /**
107     \brief comparison operator
108
109     \return \a rhs < \a lhs
110
111     \relates DataWeight
112   */
113  bool operator>(const DataWeight&, const DataWeight&);
114
115  /**
116     \brief comparison operator
117
118     \return true if \a lhs < \a rhs or lhs == rhs
119
120     \relates DataWeight
121   */
122  bool operator<=(const DataWeight&, const DataWeight&);
123
124  /**
125     \brief comparison operator
126
127     \return true if \a lhs > rhs or \a lhs == \a rhs
128
129     \relates DataWeight
130   */
131  bool operator>=(const DataWeight&, const DataWeight&);
132
133
134}}} // of namespace utility, yat, and theplu
135
136#endif
Note: See TracBrowser for help on using the repository browser.