OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / advance.h
1 /*
2  *  Copyright 2008-2013 NVIDIA Corporation
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17
18 /*! \file advance.h
19  *  \brief Advance an iterator by a given distance.
20  */
21
22 #pragma once
23
24 #include <thrust/detail/config.h>
25
26 namespace thrust
27 {
28
29
30 /*! \addtogroup iterators
31  *  \{
32  */
33
34 /*! \p advance(i, n) increments the iterator \p i by the distance \p n. 
35  *  If <tt>n > 0</tt> it is equivalent to executing <tt>++i</tt> \p n
36  *  times, and if <tt>n < 0</tt> it is equivalent to executing <tt>--i</tt>
37  *  \p n times. If <tt>n == 0</tt>, the call has no effect.
38  *
39  *  \param i The iterator to be advanced.
40  *  \param n The distance by which to advance the iterator.
41  *
42  *  \tparam InputIterator is a model of <a href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a>.
43  *  \tparam Distance is an integral type that is convertible to \p InputIterator's distance type. 
44  *
45  *  \pre \p n shall be negative only for bidirectional and random access iterators.
46  *
47  *  The following code snippet demonstrates how to use \p advance to increment
48  *  an iterator a given number of times.
49  *
50  *  \code
51  *  #include <thrust/advance.h>
52  *  #include <thrust/device_vector.h>
53  *  ...
54  *  thrust::device_vector<int> vec(13);
55  *  thrust::device_vector<int>::iterator iter = vec.begin();
56  *
57  *  thrust::advance(iter, 7);
58  *
59  *  // iter - vec.begin() == 7
60  *  \endcode
61  *
62  *  \see http://www.sgi.com/tech/stl/advance.html
63  */
64 template <typename InputIterator, typename Distance>
65 void advance(InputIterator& i, Distance n);
66
67 /*! \} // end iterators
68  */
69
70 } // end thrust
71
72 #include <thrust/detail/advance.inl>
73