Changeset 1365 for trunk/yat


Ignore:
Timestamp:
Jul 10, 2008, 10:30:07 PM (13 years ago)
Author:
Peter
Message:

working on ticket:369 - created a DataIterator? that seems to work. However, it can't work in a mutable fashion because of limitations in iterator_traits (see #391). Also there should be a WeightIterator? before ticket:369 can be closed

Location:
trunk/yat/utility
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/DataIterator.h

    r1363 r1365  
    1 #ifndef _theplu_yat_utility_iterator_data_
    2 #define _theplu_yat_utility_iterator_data_
     1#ifndef _theplu_yat_utility_data_iterator_
     2#define _theplu_yat_utility_data_iterator_
    33
    44// $Id$
     
    2525*/
    2626
    27 #include "yat_assert.h"
     27#include <boost/iterator/iterator_adaptor.hpp>
    2828
    2929namespace theplu {
     
    3232
    3333  /**
    34      @brief Iterator
     34     @brief DataIterator
    3535  */
    36   template<typename T>
    37   class IteratorData
     36  template<typename Base>
     37  class DataIterator
     38    : public boost::iterator_adaptor<
     39    DataIterator<Base>               // Derived
     40    , Base                          // Base
     41    , double              // Value
     42    , boost::forward_traversal_tag    // CategoryOrTraversal
     43    , double
     44    >
     45
    3846  {
    3947  public:
    40     IteratorData(T);
     48    explicit DataIterator(Base b)
     49      : DataIterator::iterator_adaptor_(b) {}
     50
     51    double operator*(void) const
     52    { return iterator_traits<Base>().data(this->base()); }
    4153
    4254  private:
    43     T base_;
    4455  };
    4556
    46   template<typename T>
    47   IteratorData<T>::IteratorData(T base)
    48     : base_(base)
    49   {}
     57  /**
     58     \brief convenient function to create DataIterator
     59
     60     Convenient function in same fashion as std::make_pair.
     61   */
     62  template<typename Base>
     63  DataIterator<Base> make_data_iterator(Base base)
     64  {
     65    return DataIterator<Base>(base);
     66  }
     67 
    5068
    5169
  • trunk/yat/utility/Makefile.am

    r1364 r1365  
    3838include_utility_HEADERS = \
    3939  Alignment.h ColumnStream.h CommandLine.h \
    40   Container2DIterator.h \
    41   Exception.h FileUtil.h Index.h IteratorData.h \
     40  Container2DIterator.h DataIterator.h \
     41  Exception.h FileUtil.h Index.h \
    4242  IteratorPolicy.h iterator_traits.h \
    4343  kNNI.h Matrix.h NNI.h \
  • trunk/yat/utility/iterator_traits.h

    r1275 r1365  
    135135     This class must be implemented for every iterator that can be weighted.
    136136
    137      \see StrideIterator and Iterator
     137     \see StrideIterator and Container2DIterator
    138138   */
    139139  template <class Iter>
Note: See TracChangeset for help on using the changeset viewer.