Changeset 2151


Ignore:
Timestamp:
Jan 17, 2010, 6:29:47 AM (12 years ago)
Author:
Peter
Message:

make the iterator_traits class more generic and adding a test for qQuantileNormalizer

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/iterator_test.cc

    r2119 r2151  
    6363void test_pair_second_iterator(test::Suite&);
    6464
     65void test_iterator_traits(test::Suite& suite);
    6566void test_stride_iterator(test::Suite& suite);
    6667void test_weighted_iterator(test::Suite& suite);
     
    7677  suite.out() << "testing boost_util\n";
    7778  test_boost_util(suite);
     79  test_iterator_traits(suite);
    7880  suite.out() << "testing pair_second_iterator\n";
    7981  test_pair_second_iterator(suite);
     
    287289}
    288290
     291
     292void test_iterator_traits(test::Suite& suite)
     293{
     294  typedef std::vector<utility::DataWeight> WeightVector;
     295  WeightVector vec(1);
     296  utility::iterator_traits<WeightVector::const_iterator> traits;
     297  double w = traits.weight(vec.begin());
     298  suite.add(suite.equal(w, 1.0));
     299}
     300
     301
    289302void test_stride_iterator(test::Suite& suite)
    290303{
  • trunk/test/normalization_test.cc

    r2150 r2151  
    194194         boost::random_access_iterator_archetype<double>(),
    195195         boost::mutable_random_access_iterator_archetype<double>());
     196    using utility::DataWeight;
     197    qQuantileNormalizer qqn4(boost::forward_iterator_archetype<DataWeight>(),
     198                             boost::forward_iterator_archetype<DataWeight>(),
     199                             100);
     200    qqn4(boost::random_access_iterator_archetype<DataWeight>(),
     201         boost::random_access_iterator_archetype<DataWeight>(),
     202         boost::mutable_random_access_iterator_archetype<DataWeight>());
    196203  }
    197204}
  • trunk/yat/utility/iterator_traits.h

    r2119 r2151  
    232232       \return reference to data of iterator
    233233    */
    234     data_reference data(Iter iter) const { return iter->data(); }
     234    data_reference data(Iter iter) const { return (*iter).data(); }
    235235
    236236    /**
    237237       \return reference to weight of iterator
    238238    */
    239     weight_reference weight(Iter iter) const { return iter->weight(); }
     239    weight_reference weight(Iter iter) const { return (*iter).weight(); }
    240240  };
    241241
     
    259259       \return const reference to data of iterator
    260260    */
    261     data_reference data(Iter iter) const { return iter->data(); }
     261    data_reference data(Iter iter) const { return (*iter).data(); }
    262262
    263263    /**
    264264       \return const reference to weight of iterator
    265265    */
    266     weight_reference weight(Iter iter) const { return iter->weight(); }
     266    weight_reference weight(Iter iter) const { return (*iter).weight(); }
    267267  };
    268268
Note: See TracChangeset for help on using the changeset viewer.