Changeset 3548


Ignore:
Timestamp:
Jan 1, 2017, 5:56:44 AM (5 years ago)
Author:
Peter
Message:

The concept 'Distance' now requires that operator() works on iterator
that are readable and forward traversal, i.e., the previously implicit
requirement that iterator's reference type is lvalue is
dropped. closes #873

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r3485 r3548  
    44
    55version 0.14 (released NOT YET)
     6  - The concept 'Distance' now requires that operator() works on
     7    iterator that are readable and forward traversal, i.e., the
     8    previously implicit requirement that iterator's reference type is
     9    lvalue is dropped (ticket #873)
    610  - libbam support is marked deprecated; use htslib.
    711  - A new (private) pure virtual function assign(const VectorBase&)
  • trunk/doc/concepts.doxygen

    r3322 r3548  
    293293
    294294\ref concept_distance is a concept for classes implementing different
    295 alternatives to calculate the distance between two points.
     295alternatives to calculate the distance between two ranges. For details
     296on requirements needed for a class modelling the concept \ref
     297concept_distance refer to section below, but a convenient way to
     298implement a class is to use class theplu::yat::statistics::Distance as
     299base class.
    296300
    297301\section concept_distance_requirments Requirements
     
    307311
    308312\verbatim
    309 template<typename Iter1, typename Iter2>
    310 double  operator() (Iter1 beg1, Iter1 end1, Iter2 beg2) const
     313template<typename Iterator1, typename Iterator2>
     314double  operator() (Iterator1 beg1, Iterator1 end1, Iterator2 beg2) const
    311315\endverbatim
    312316
     
    314318elements of two ranges. The first range is given by [\a beg1, \a end1)
    315319and the second range starts with \a beg2 and has the same length as
    316 the first range. The function should support iterators of the category
    317 std::forward_iterator. The function should provide both a fast
    318 calculation for unweighted iterators and a calculation for weighted
    319 iterators. The latter correspond to the case where elements in a range
    320 have both a value and a weight. The selection between unweighted and
    321 weighted implementations should utilize
     320the first range. The function should support iterators that model \ref
     321concept_data_iterator and \forward_traversal_iterator, in other words,
     322the function should not assume any functionality not guaranteed by
     323concepts \forward_traversal_iterator and \readable_iterator.
     324
     325As \ref concept_data_iterator should be supported implies that class
     326should support \ref concept_weighted_iterator. Typically a \ref
     327concept_distance class has a fast calculation for the case when
     328neither of the two input ranges is weighted, and a separate function
     329taking care of weights. A convenient way to select between unweighted and
     330weighted implementations is to utilize tag structs
    322331theplu::yat::utility::unweighted_iterator_tag and
    323 theplu::yat::utility::weighted_iterator_tag. Moreover
    324 theplu::yat::utility::weighted_if_any2 should be utilized to provide a
    325 weighted implementation if any of the two ranges is weighted, and an
    326 unweighted implementation when both ranges are unweighted.
     332theplu::yat::utility::weighted_iterator_tag as returned from meta-function
     333theplu::yat::utility::weighted_if_any2.
     334
     335The class theplu::yat::utility::DistanceConcept an be used to test
     336that a class fulfills these requirements.
    327337
    328338\section concept_distance_implementations Implementations
  • trunk/yat/statistics/Distance.h

    r3540 r3548  
    9090    double operator()(Iterator1 beg1, Iterator1 end1, Iterator2 beg2) const
    9191    {
    92       BOOST_CONCEPT_ASSERT((Derived));
    9392      using utility::weighted_if_any2;
    9493      typename weighted_if_any2<Iterator1, Iterator2>::type tag;
  • trunk/yat/utility/DataWeightProxy.h

    r3460 r3548  
    2727
    2828#include <boost/concept/assert.hpp>
     29#include <boost/iterator/iterator_concepts.hpp>
    2930#include <boost/iterator/iterator_traits.hpp>
    3031
  • trunk/yat/utility/WeightedIteratorArchetype.h

    r3534 r3548  
    135135    : public boost::iterator_facade<
    136136    WeightedIteratorArchetype<AccessCategory, TraversalCategory>
    137     , utility::DataWeight
     137    , DataWeight
    138138    , TraversalCategory
    139139    , typename detail::weighted_iterator_archetype::Reference<AccessCategory>::type
  • trunk/yat/utility/concept_check.h

    r3536 r3548  
    2727
    2828#include "iterator_traits.h"
     29#include "WeightedIteratorArchetype.h"
    2930
    3031#include <boost/concept_archetype.hpp>
    3132#include <boost/concept_check.hpp>
     33#include <boost/iterator/iterator_archetypes.hpp>
    3234#include <boost/iterator/iterator_concepts.hpp>
    3335
     
    281283    BOOST_CONCEPT_USAGE(DistanceConcept)
    282284    {
    283       boost::forward_iterator_archetype<double> unweighted;
    284       boost::forward_iterator_archetype<DataWeight> weighted;
     285      using boost::iterator_archetypes::readable_iterator_t;
     286      using boost::forward_traversal_tag;
     287      boost::iterator_archetype<double, readable_iterator_t,
     288                                forward_traversal_tag> unweighted;
     289      WeightedIteratorArchetype<readable_iterator_t, forward_traversal_tag>
     290        weighted;
    285291      double d=0;
    286292      d += distance_(unweighted, unweighted, unweighted);
Note: See TracChangeset for help on using the changeset viewer.