source: trunk/yat/utility/DataWeight.h @ 1797

Last change on this file since 1797 was 1797, checked in by Peter, 15 years ago

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1#ifndef _theplu_yat_utility_data_weight_
2#define _theplu_yat_utility_data_weight_
3
4// $Id: DataWeight.h 1797 2009-02-12 18:07:10Z 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  bool operator==(const DataWeight& lhs, const DataWeight& rhs);
83
84  /**
85     \brief inequality operator
86
87     \return true if lhs.data() != rhs.data()
88   */
89  bool operator!=(const DataWeight&, const DataWeight&);
90
91  /**
92     \brief comparison operator
93
94     \return true if lhs data is less than rhs data
95   */
96  bool operator<(const DataWeight&, const DataWeight&);
97
98  /**
99     \brief comparison operator
100
101     \return true if lhs data is greater than rhs data
102   */
103  bool operator>(const DataWeight&, const DataWeight&);
104
105  /**
106     \brief comparison operator
107
108     \return true if lhs.data() <= rhs.data()
109   */
110  bool operator<=(const DataWeight&, const DataWeight&);
111
112  /**
113     \brief comparison operator
114
115     \return true if lhs.data() >= rhs.data()
116   */
117  bool operator>=(const DataWeight&, const DataWeight&);
118
119
120}}} // of namespace utility, yat, and theplu
121
122#endif
Note: See TracBrowser for help on using the repository browser.