Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / algorithm / cxx11 / iota.hpp @ 2486

History | View | Annotate | Download (2.1 kB)

1 2486 sjacqu01
/*
2 2486 sjacqu01
   Copyright (c) Marshall Clow 2008-2012.
3 2486 sjacqu01

4 2486 sjacqu01
   Distributed under the Boost Software License, Version 1.0. (See accompanying
5 2486 sjacqu01
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 2486 sjacqu01
*/
7 2486 sjacqu01
8 2486 sjacqu01
/// \file  iota.hpp
9 2486 sjacqu01
/// \brief Generate an increasing series
10 2486 sjacqu01
/// \author Marshall Clow
11 2486 sjacqu01
12 2486 sjacqu01
#ifndef BOOST_ALGORITHM_IOTA_HPP
13 2486 sjacqu01
#define BOOST_ALGORITHM_IOTA_HPP
14 2486 sjacqu01
15 2486 sjacqu01
#include <numeric>
16 2486 sjacqu01
17 2486 sjacqu01
#include <boost/range/begin.hpp>
18 2486 sjacqu01
#include <boost/range/end.hpp>
19 2486 sjacqu01
20 2486 sjacqu01
namespace boost { namespace algorithm {
21 2486 sjacqu01
22 2486 sjacqu01
/// \fn iota ( ForwardIterator first, ForwardIterator last, T value )
23 2486 sjacqu01
/// \brief Generates an increasing sequence of values, and stores them in [first, last)
24 2486 sjacqu01
///
25 2486 sjacqu01
/// \param first    The start of the input sequence
26 2486 sjacqu01
/// \param last     One past the end of the input sequence
27 2486 sjacqu01
/// \param value    The initial value of the sequence to be generated
28 2486 sjacqu01
/// \note           This function is part of the C++2011 standard library.
29 2486 sjacqu01
///  We will use the standard one if it is available,
30 2486 sjacqu01
///  otherwise we have our own implementation.
31 2486 sjacqu01
template <typename ForwardIterator, typename T>
32 2486 sjacqu01
void iota ( ForwardIterator first, ForwardIterator last, T value )
33 2486 sjacqu01
{
34 2486 sjacqu01
    for ( ; first != last; ++first, ++value )
35 2486 sjacqu01
        *first = value;
36 2486 sjacqu01
}
37 2486 sjacqu01
38 2486 sjacqu01
/// \fn iota ( Range &r, T value )
39 2486 sjacqu01
/// \brief Generates an increasing sequence of values, and stores them in the input Range.
40 2486 sjacqu01
///
41 2486 sjacqu01
/// \param r        The input range
42 2486 sjacqu01
/// \param value    The initial value of the sequence to be generated
43 2486 sjacqu01
///
44 2486 sjacqu01
template <typename Range, typename T>
45 2486 sjacqu01
void iota ( Range &r, T value )
46 2486 sjacqu01
{
47 2486 sjacqu01
    boost::algorithm::iota (boost::begin(r), boost::end(r), value);
48 2486 sjacqu01
}
49 2486 sjacqu01
50 2486 sjacqu01
51 2486 sjacqu01
/// \fn iota_n ( OutputIterator out, T value, std::size_t n )
52 2486 sjacqu01
/// \brief Generates an increasing sequence of values, and stores them in the input Range.
53 2486 sjacqu01
///
54 2486 sjacqu01
/// \param out      An output iterator to write the results into
55 2486 sjacqu01
/// \param value    The initial value of the sequence to be generated
56 2486 sjacqu01
/// \param n        The number of items to write
57 2486 sjacqu01
///
58 2486 sjacqu01
template <typename OutputIterator, typename T>
59 2486 sjacqu01
OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
60 2486 sjacqu01
{
61 2486 sjacqu01
    for ( ; n > 0; --n, ++value )
62 2486 sjacqu01
        *out++ = value;
63 2486 sjacqu01
64 2486 sjacqu01
    return out;
65 2486 sjacqu01
}
66 2486 sjacqu01
67 2486 sjacqu01
}}
68 2486 sjacqu01
69 2486 sjacqu01
#endif  // BOOST_ALGORITHM_IOTA_HPP