Changeset 2263


Ignore:
Timestamp:
May 27, 2010, 12:13:07 AM (12 years ago)
Author:
Peter
Message:

adding a class DataIteratorConcept? for concept data iterator. refs #624

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/concepts.doxygen

    r2250 r2263  
    444444Examples of concept \ref concept_data_iterator include:
    445445  - theplu::yat::utility::Matrix::iterator,
     446  - theplu::yat::utility::MatrixWeighted::iterator,
    446447  - theplu::yat::classifier::MatrixLookup::const_iterator,
    447448  - theplu::yat::classifier::MatrixLookupWeighted::const_iterator
  • trunk/test/concept_test.cc

    r2260 r2263  
    5353  BOOST_CONCEPT_ASSERT((Mutable_Container2D<MatrixWeighted>));
    5454 
    55 
     55  // concept DataIterator
     56  using classifier::MatrixLookup;
     57  using classifier::MatrixLookupWeighted;
     58  BOOST_CONCEPT_ASSERT((DataIteratorConcept<Matrix::iterator>));
     59  BOOST_CONCEPT_ASSERT((DataIteratorConcept<MatrixWeighted::iterator>));
     60  BOOST_CONCEPT_ASSERT((DataIteratorConcept<MatrixLookup::const_iterator>));
     61  BOOST_CONCEPT_ASSERT((DataIteratorConcept<MatrixLookupWeighted::const_iterator>));
    5662
    5763  return suite.return_value();
  • trunk/yat/normalizer/Gauss.h

    r2161 r2263  
    2525
    2626#include "Spearman.h"
     27#include "yat/utility/concept_check.h"
    2728#include "yat/utility/iterator_traits.h"
    2829
     
    6970                    RandomAccessIter2 result) const
    7071    {
     72      BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIter1>));
     73      BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIter2>));
    7174      BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIter1>));
    7275      BOOST_CONCEPT_ASSERT((boost::Mutable_RandomAccessIterator<RandomAccessIter2>));
  • trunk/yat/normalizer/qQuantileNormalizer.h

    r2210 r2263  
    2525
    2626#include "yat/regression/CSplineInterpolation.h"
     27#include "yat/utility/concept_check.h"
    2728#include "yat/utility/DataIterator.h"
    2829#include "yat/utility/DataWeight.h"
     
    258259    BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator1>));
    259260    BOOST_CONCEPT_ASSERT((boost::Mutable_RandomAccessIterator<RandomAccessIterator2>));
     261    BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIterator1>));
     262    BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIterator2>));
    260263    utility::check_iterator_is_unweighted(first);
    261264    utility::check_iterator_is_unweighted(result);
     
    317320    BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator1>));
    318321    BOOST_CONCEPT_ASSERT((boost::Mutable_RandomAccessIterator<RandomAccessIterator2>));
     322    BOOST_CONCEPT_ASSERT((utility::DataIterator<RandomAccessIterator1>));
     323    BOOST_CONCEPT_ASSERT((utility::DataIterator<RandomAccessIterator2>));
    319324    // copy the weights
    320325    detail::copy_weight_if_weighted(first, last, result);
     
    381386  {
    382387    BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
     388    BOOST_CONCEPT_ASSERT((utility::DataIterator<ForwardIterator>));
    383389    build(first, last, N,
    384390          typename utility::weighted_iterator_traits<ForwardIterator>::type());
  • trunk/yat/statistics/Histogram.h

    r2202 r2263  
    2828
    2929#include "AveragerWeighted.h"
     30#include "yat/utility/concept_check.h"
    3031#include "yat/utility/iterator_traits.h"
    3132
     
    222223  {
    223224    BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
     225    BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<ForwardIterator>));
    224226    utility::iterator_traits<ForwardIterator> traits;
    225227    while (first!=last) {
  • trunk/yat/statistics/Percentiler.h

    r2202 r2263  
    2424*/
    2525
     26#include "yat/utility/concept_check.h"
    2627#include "yat/utility/DataWeight.h"
    2728#include "yat/utility/iterator_traits.h"
     
    9798    {
    9899      BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
     100      BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIterator>));
    99101      return calculate(first, last, sorted_,
    100102       typename utility::weighted_iterator_traits<RandomAccessIterator>::type());
  • trunk/yat/statistics/utility.h

    r2202 r2263  
    3131#include "yat/classifier/DataLookupWeighted1D.h"
    3232#include "yat/classifier/Target.h"
     33#include "yat/utility/concept_check.h"
    3334#include "yat/utility/deprecate.h"
    3435#include "yat/utility/iterator_traits.h"
    3536#include "yat/utility/VectorBase.h"
    3637#include "yat/utility/yat_assert.h"
     38
     39#include <boost/concept_check.hpp>
    3740
    3841#include <algorithm>
     
    202205             bool sorted)
    203206  {
     207    BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
     208    BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIterator>));
    204209    double m = median(first, last, sorted);
    205210    typedef typename std::iterator_traits<RandomAccessIterator>::value_type T;
     
    232237  {
    233238    BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
     239    BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIterator>));
    234240    // range is one value only is a special case
    235241    if (first+1 == last)
  • trunk/yat/utility/concept_check.h

    r2260 r2263  
    2222  along with yat. If not, see <http://www.gnu.org/licenses/>.
    2323*/
     24
     25#include "iterator_traits.h"
    2426
    2527#include <boost/concept_check.hpp>
     
    136138  };
    137139
     140
     141  /**
     142     \brief Concept check for \trivial_iterator
     143
     144     This class is intended to be used in a <a
     145     href="\boost_url/concept_check/using_concept_check.htm">
     146     BOOST_CONCEPT_ASSERT </a>
     147
     148     \code
     149     template<class Iterator>
     150     void some_function(const Iterator& it)
     151     {
     152     BOOST_CONCEPT_ASSERT((TrivialIterator<Iterator>));
     153     ...
     154     }
     155     \endcode
     156  */
     157  template <class T>
     158  class TrivialIterator
     159    : public boost::Assignable<T>
     160    , public boost::EqualityComparable<T>
     161    , public boost::DefaultConstructible<T>
     162
     163  {
     164  public:
     165    /// iterator_category
     166    typedef typename std::iterator_traits<T>::iterator_category iterator_category;
     167    /// value_type
     168    typedef typename std::iterator_traits<T>::value_type value_type;
     169    /// difference_type
     170    typedef typename std::iterator_traits<T>::difference_type difference_type;
     171    /// pointer
     172    typedef typename std::iterator_traits<T>::pointer pointer;
     173    /// reference
     174    typedef typename std::iterator_traits<T>::reference reference;
     175
     176    /**
     177       \brief function doing the concept test
     178     */
     179    BOOST_CONCEPT_USAGE(TrivialIterator)
     180    {
     181      T t;
     182      value_ = *t;
     183    }
     184  private:
     185    value_type value_;
     186  };
     187
     188  /**
     189     \brief Concept check for \ref concept_data_iterator
     190
     191     This class is intended to be used in a <a
     192     href="\boost_url/concept_check/using_concept_check.htm">
     193     BOOST_CONCEPT_ASSERT </a>
     194
     195     \code
     196     template<class Iterator>
     197     void some_function(const Iterator& it)
     198     {
     199     BOOST_CONCEPT_ASSERT((DataIteratorConcept<Iterator>));
     200     ...
     201     }
     202     \endcode
     203  */
     204  template <class T>
     205  class DataIteratorConcept
     206  {
     207  public:
     208    /// tag
     209    typedef typename weighted_iterator_traits<T>::type tag;
     210    /// value_type
     211    typedef typename std::iterator_traits<T>::value_type value_type;
     212
     213    /**
     214       \brief function doing the concept test
     215     */
     216    BOOST_CONCEPT_USAGE(DataIteratorConcept)
     217    {
     218      BOOST_CONCEPT_ASSERT((TrivialIterator<T>));
     219      tag t;
     220      constraints(t);
     221    }
     222  private:
     223    void constraints(yat::utility::unweighted_iterator_tag t) const
     224    {
     225      BOOST_CONCEPT_ASSERT((boost::Convertible<value_type, double>));
     226    }
     227
     228    void constraints(yat::utility::weighted_iterator_tag t) const
     229    {
     230      BOOST_CONCEPT_ASSERT((boost::Convertible<value_type, DataWeight>));
     231    }
     232
     233  };
     234
    138235}}} // of namespace utility, yat, and theplu
    139236#endif
Note: See TracChangeset for help on using the changeset viewer.