Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:22

0001 /* 
0002    Copyright (c) Marshall Clow 2008-2012.
0003 
0004    Distributed under the Boost Software License, Version 1.0. (See accompanying
0005    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 */
0007 
0008 /// \file  iota.hpp
0009 /// \brief Generate an increasing series
0010 /// \author Marshall Clow
0011 
0012 #ifndef BOOST_ALGORITHM_IOTA_HPP
0013 #define BOOST_ALGORITHM_IOTA_HPP
0014 
0015 #include <boost/config.hpp>
0016 #include <boost/range/begin.hpp>
0017 #include <boost/range/end.hpp>
0018 
0019 namespace boost { namespace algorithm {
0020 
0021 /// \fn iota ( ForwardIterator first, ForwardIterator last, T value )
0022 /// \brief Generates an increasing sequence of values, and stores them in [first, last)
0023 /// 
0024 /// \param first    The start of the input sequence
0025 /// \param last     One past the end of the input sequence
0026 /// \param value    The initial value of the sequence to be generated
0027 /// \note           This function is part of the C++2011 standard library.
0028 template <typename ForwardIterator, typename T>
0029 BOOST_CXX14_CONSTEXPR void iota ( ForwardIterator first, ForwardIterator last, T value )
0030 {
0031     for ( ; first != last; ++first, ++value )
0032         *first = value;
0033 }
0034 
0035 /// \fn iota ( Range &r, T value )
0036 /// \brief Generates an increasing sequence of values, and stores them in the input Range.
0037 /// 
0038 /// \param r        The input range
0039 /// \param value    The initial value of the sequence to be generated
0040 ///
0041 template <typename Range, typename T>
0042 BOOST_CXX14_CONSTEXPR void iota ( Range &r, T value )
0043 {
0044     boost::algorithm::iota (boost::begin(r), boost::end(r), value);
0045 }
0046 
0047 
0048 /// \fn iota_n ( OutputIterator out, T value, std::size_t n )
0049 /// \brief Generates an increasing sequence of values, and stores them in the input Range.
0050 /// 
0051 /// \param out      An output iterator to write the results into
0052 /// \param value    The initial value of the sequence to be generated
0053 /// \param n        The number of items to write
0054 ///
0055 template <typename OutputIterator, typename T>
0056 BOOST_CXX14_CONSTEXPR OutputIterator iota_n ( OutputIterator out, T value, std::size_t n )
0057 {
0058     for ( ; n > 0; --n, ++value )
0059         *out++ = value;
0060 
0061     return out;
0062 }
0063 
0064 }}
0065 
0066 #endif  // BOOST_ALGORITHM_IOTA_HPP