source: trunk/yat/utility/DataIterator.h @ 1366

Last change on this file since 1366 was 1366, checked in by Peter, 13 years ago

adding missing docs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1#ifndef _theplu_yat_utility_data_iterator_
2#define _theplu_yat_utility_data_iterator_
3
4// $Id: DataIterator.h 1366 2008-07-10 23:03:00Z peter $
5
6/*
7  Copyright (C) 2008 Peter Johansson
8
9  This file is part of the yat library, http://trac.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 2 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24  02111-1307, USA.
25*/
26
27#include <boost/iterator/iterator_adaptor.hpp>
28
29namespace theplu {
30namespace yat {
31namespace utility {
32
33  /**
34     @brief DataIterator
35  */
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
46  {
47  public:
48    /**
49       \brief Constructor from \a Base iterator
50     */
51    explicit DataIterator(Base b)
52      : DataIterator::iterator_adaptor_(b) {}
53
54    /**
55       using iterator_traits::data on Base iterator
56
57       \return data
58     */
59    double operator*(void) const
60    { return iterator_traits<Base>().data(this->base()); }
61
62  private:
63  };
64
65  /**
66     \brief convenient function to create DataIterator
67
68     Convenient function in same fashion as std::make_pair.
69   */
70  template<typename Base>
71  DataIterator<Base> make_data_iterator(Base base)
72  {
73    return DataIterator<Base>(base);
74  }
75 
76
77
78}}} // of namespace utility, yat, and theplu
79
80#endif
Note: See TracBrowser for help on using the repository browser.