Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / accumulators / statistics / times2_iterator.hpp @ 2486

History | View | Annotate | Download (1.6 kB)

1
///////////////////////////////////////////////////////////////////////////////
2
// times2_iterator.hpp
3
//
4
//  Copyright 2006 Eric Niebler. Distributed under the Boost
5
//  Software License, Version 1.0. (See accompanying file
6
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7

    
8
#ifndef BOOST_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006
9
#define BOOST_ACCUMULATORS_STATISTICS_TIMES2_ITERATOR_HPP_DE_01_01_2006
10

    
11
#include <functional>
12
#include <boost/range/begin.hpp>
13
#include <boost/range/end.hpp>
14
#include <boost/range/iterator_range.hpp>
15
#include <boost/iterator/transform_iterator.hpp>
16
#include <boost/iterator/counting_iterator.hpp>
17
#include <boost/iterator/permutation_iterator.hpp>
18

    
19
namespace boost { namespace accumulators
20
{
21

    
22
namespace detail
23
{
24
    typedef transform_iterator<
25
        std::binder1st<std::multiplies<std::size_t> >
26
      , counting_iterator<std::size_t>
27
    > times2_iterator;
28

    
29
    inline times2_iterator make_times2_iterator(std::size_t i)
30
    {
31
        return make_transform_iterator(
32
            make_counting_iterator(i)
33
          , std::bind1st(std::multiplies<std::size_t>(), 2)
34
        );
35
    }
36

    
37

    
38
    ///////////////////////////////////////////////////////////////////////////////
39
    // lvalue_index_iterator
40
    template<typename Base>
41
    struct lvalue_index_iterator
42
      : Base
43
    {
44
        lvalue_index_iterator(Base base)
45
          : Base(base)
46
        {
47
        }
48

    
49
        typename Base::reference operator [](typename Base::difference_type n) const
50
        {
51
            return *(*this + n);
52
        }
53
    };
54
} // namespace detail
55

    
56
}}
57

    
58
#endif