Changeset 1533


Ignore:
Timestamp:
Sep 25, 2008, 2:02:52 PM (13 years ago)
Author:
Peter
Message:

refs #368 - introducing proxy class

Location:
trunk
Files:
1 added
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r1513 r1533  
    3333  commandline_test \
    3434  consensus_inputranker_test data_lookup_1d_test  \
    35   data_weight_test distance_test \
     35  data_weight_test data_weight_proxy_test distance_test \
    3636  ensemble_test feature_selection_test fileutil_test \
    3737  index_test inputranker_test \
     
    6565data_lookup_1d_test_SOURCES = data_lookup_1d_test.cc
    6666data_weight_test_SOURCES = data_weight_test.cc
     67data_weight_proxy_test_SOURCES = data_weight_proxy_test.cc
    6768distance_test_SOURCES = distance_test.cc
    6869ensemble_test_SOURCES = ensemble_test.cc
  • trunk/yat/utility/DataWeight.h

    r1487 r1533  
    2929  /**
    3030     \brief Holds a pair of data and associated weight
     31
     32     \since New in yat 0.5
    3133  */
    3234  class DataWeight
  • trunk/yat/utility/DataWeightProxy.cc

    r1532 r1533  
    2020*/
    2121
    22 #include "DataWeight.h"
     22#include "DataWeightProxy.h"
    2323
    2424namespace theplu {
     
    2626namespace utility { 
    2727
    28   DataWeight::DataWeight(double data, double weight)
     28  DataWeightProxy::DataWeightProxy(double& data, double& weight)
    2929    : data_(data), weight_(weight) {}
    3030
    31 
    32   double& DataWeight::data(void)
     31  double& DataWeightProxy::data(void)
    3332  {
    3433    return data_;
     
    3635
    3736
    38   const double& DataWeight::data(void) const
     37  const double& DataWeightProxy::data(void) const
    3938  {
    4039    return data_;
    4140  }
    4241
    43   double& DataWeight::weight(void)
     42
     43  double& DataWeightProxy::weight(void)
    4444  {
    4545    return weight_;
     
    4747
    4848
    49   const double& DataWeight::weight(void) const
     49  const double& DataWeightProxy::weight(void) const
    5050  {
    5151    return weight_;
    5252  }
    5353
    54 
    55   bool operator==(const DataWeight& lhs, const DataWeight& rhs)
    56   {
    57     return lhs.data() == rhs.data();
    58   }
    59 
    60 
    61   bool operator!=(const DataWeight& lhs, const DataWeight& rhs)
    62   {
    63     return ! (lhs == rhs);
    64   }
    65 
    66 
    67   bool operator<(const DataWeight& lhs, const DataWeight& rhs)
    68   {
    69     return lhs.data() < rhs.data();
    70   }
    71 
    72 
    73   bool operator>(const DataWeight& lhs, const DataWeight& rhs)
    74   {
    75     return rhs < lhs;
    76   }
    77 
    78 
    79   bool operator<=(const DataWeight& lhs, const DataWeight& rhs)
    80   {
    81     return rhs > lhs;
    82   }
    83 
    84 
    85   bool operator>=(const DataWeight& lhs, const DataWeight& rhs)
    86   {
    87     return rhs < lhs;
    88   }
    89 
    90 
    9154}}} // of namespace utility, yat, and theplu
  • trunk/yat/utility/DataWeightProxy.h

    r1532 r1533  
    1 #ifndef _theplu_yat_utility_data_weight_
    2 #define _theplu_yat_utility_data_weight_
     1#ifndef _theplu_yat_utility_data_weight_proxy_
     2#define _theplu_yat_utility_data_weight_proxy_
    33
    44// $Id$
     
    2828
    2929  /**
    30      \brief Holds a pair of data and associated weight
     30     \internal
     31
     32     \brief Proxy class for DataWeight
    3133  */
    32   class DataWeight
     34  class DataWeightProxy
    3335  {
    3436  public:
     
    3941       \param weight weight value to hold
    4042     */
    41     explicit DataWeight(double data=0.0, double weight=1.0);
     43    DataWeightProxy(double& data, double& weight);
    4244
    4345    /**
     
    6163    const double& weight(void) const;
    6264  private:
    63     double data_;
    64     double weight_;
    65     // using compiler generated copy
    66     // DataWeight(const DataWeight&)
    67     // DataWeight& operator=(const DataWeight&);
     65    double& data_;
     66    double& weight_;
     67
     68    // no copying
     69    DataWeightProxy(const DataWeightProxy&);
     70    DataWeightProxy& operator=(const DataWeightProxy&);
    6871  };
    69 
    70   /**
    71      \brief equality operator
    72 
    73      \return true if data are equal
    74    */
    75   bool operator==(const DataWeight&, const DataWeight&);
    76 
    77   /**
    78      \brief inequality operator
    79 
    80      \return true if data are inequal
    81    */
    82   bool operator!=(const DataWeight&, const DataWeight&);
    83 
    84   /**
    85      \brief comparison operator
    86 
    87      \return true if lhs data is less than rhs data
    88    */
    89   bool operator<(const DataWeight&, const DataWeight&);
    90 
    91   /**
    92      \brief comparison operator
    93 
    94      \return true if lhs data is greater than rhs data
    95    */
    96   bool operator>(const DataWeight&, const DataWeight&);
    97 
    98   /**
    99      \brief comparison operator
    100 
    101      \return true if  rhs > lhs
    102    */
    103   bool operator<=(const DataWeight&, const DataWeight&);
    104 
    105   /**
    106      \brief comparison operator
    107 
    108      \return true if  rhs < lhs
    109    */
    110   bool operator>=(const DataWeight&, const DataWeight&);
    111 
    11272
    11373}}} // of namespace utility, yat, and theplu
  • trunk/yat/utility/Makefile.am

    r1527 r1533  
    2323noinst_LTLIBRARIES = libutility.la
    2424libutility_la_SOURCES = \
    25   Alignment.cc ColumnStream.cc CommandLine.cc DataWeight.cc \
     25  Alignment.cc ColumnStream.cc CommandLine.cc DataWeight.cc DataWeightProxy.cc \
    2626  FileUtil.cc Index.cc kNNI.cc \
    2727  Matrix.cc MatrixWeighted.cc NNI.cc Option.cc \
     
    3636include_utility_HEADERS = \
    3737  Alignment.h ColumnStream.h CommandLine.h \
    38   Container2DIterator.h DataIterator.h DataWeight.h \
     38  Container2DIterator.h DataIterator.h DataWeight.h DataWeightProxy.h \
    3939  deprecate.h Exception.h FileUtil.h Index.h \
    4040  IteratorPolicy.h iterator_traits.h \
Note: See TracChangeset for help on using the changeset viewer.