Skip to content
Newer
Older
100644 140 lines (120 sloc) 4.21 KB
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
1 /*
ec3e65c @wnbell updated copyright year to 2012
wnbell authored
2 * Copyright 2008-2012 NVIDIA Corporation
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
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
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
17 /*! \file swap.h
742f8c0 @jaredhoberock Ensure all files have a reasonable brief Doxygen description.
jaredhoberock authored
18 * \brief Functions for swapping the value of elements
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
19 */
20
21 #pragma once
22
4750e2b @wnbell renamed komrade->thrust
wnbell authored
23 #include <thrust/detail/config.h>
2e1e064 @jaredhoberock Port swap_ranges to the explicit dispatch path.
jaredhoberock authored
24 #include <thrust/detail/dispatchable.h>
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
25
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
26 // empty Doxygen comment below so namespace thrust's documentation will be extracted
27
28 /*!
29 */
4750e2b @wnbell renamed komrade->thrust
wnbell authored
30 namespace thrust
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
31 {
32
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
33 /*! \addtogroup utility
34 * \{
35 */
36
480c4eb @jaredhoberock Buff tuple's documentation.
jaredhoberock authored
37 /*! \addtogroup swap
38 * \{
39 */
40
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
41 /*! \p swap assigns the contents of \c a to \c b and the
42 * contents of \c b to \c a. This is used as a primitive operation
43 * by many other algorithms.
44 *
45 * \param a The first value of interest. After completion,
46 * the value of b will be returned here.
47 * \param b The second value of interest. After completion,
48 * the value of a will be returned here.
49 *
50 * \tparam Assignable is a model of <a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>.
51 *
52 * The following code snippet demonstrates how to use \p swap to
53 * swap the contents of two variables.
54 *
55 * \code
56 * #include <thrust/swap.h>
57 * ...
58 * int x = 1;
59 * int y = 2;
60 * thrust::swap(x,h);
61 *
62 * // x == 2, y == 1
63 * \endcode
64 */
65 template<typename Assignable1, typename Assignable2>
66 __host__ __device__
67 inline void swap(Assignable1 &a, Assignable2 &b);
68
480c4eb @jaredhoberock Buff tuple's documentation.
jaredhoberock authored
69 /*! \} // swap
70 */
71
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
72 /*! \} // utility
73 */
74
2e1e064 @jaredhoberock Port swap_ranges to the explicit dispatch path.
jaredhoberock authored
75
76 template<typename System,
77 typename ForwardIterator1,
78 typename ForwardIterator2>
79 ForwardIterator2 swap_ranges(thrust::detail::dispatchable_base<System> &system,
80 ForwardIterator1 first1,
81 ForwardIterator1 last1,
82 ForwardIterator2 first2);
83
84
9c73166 @wnbell more doxygen tweaking
wnbell authored
85 /*! \addtogroup copying
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
86 * \{
87 */
88
89 /*! \p swap_ranges swaps each of the elements in the range <tt>[first1, last1)</tt>
90 * with the corresponding element in the range <tt>[first2, first2 + (last1 - first1))</tt>.
91 * That is, for each integer \c n such that <tt>0 <= n < (last1 - first1)</tt>, it swaps
92 * <tt>*(first1 + n)</tt> and <tt>*(first2 + n)</tt>. The return value is
93 * <tt>first2 + (last1 - first1)</tt>.
94 *
95 * \param first1 The beginning of the first sequence to swap.
96 * \param last1 One position past the last element of the first sequence to swap.
97 * \param first2 The beginning of the second sequence to swap.
98 * \return An iterator pointing to one position past the last element of the second
99 * sequence to swap.
100 *
101 * \tparam ForwardIterator1 is a model of <a href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>,
102 * and \p ForwardIterator1's \c value_type must be convertible to \p ForwardIterator2's \c value_type.
103 * \tparam ForwardIterator2 is a model of <a href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>,
104 * and \p ForwardIterator2's \c value_type must be convertible to \p ForwardIterator1's \c value_type.
105 *
106 * The following code snippet demonstrates how to use \p swap_ranges to
4750e2b @wnbell renamed komrade->thrust
wnbell authored
107 * swap the contents of two \c thrust::device_vectors.
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
108 *
109 * \code
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
110 * #include <thrust/swap.h>
4750e2b @wnbell renamed komrade->thrust
wnbell authored
111 * #include <thrust/device_vector.h>
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
112 * ...
4750e2b @wnbell renamed komrade->thrust
wnbell authored
113 * thrust::device_vector<int> v1(2), v2(2);
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
114 * v1[0] = 1;
115 * v1[1] = 2;
116 * v2[0] = 3;
117 * v2[1] = 4;
118 *
4750e2b @wnbell renamed komrade->thrust
wnbell authored
119 * thrust::swap_ranges(v1.begin(), v1.end(), v2.begin());
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
120 *
121 * // v1[0] == 3, v1[1] == 4, v2[0] == 1, v2[1] == 2
122 * \endcode
123 *
124 * \see http://www.sgi.com/tech/stl/swap_ranges.html
125 * \see \c swap
126 */
127 template<typename ForwardIterator1,
128 typename ForwardIterator2>
129 ForwardIterator2 swap_ranges(ForwardIterator1 first1,
130 ForwardIterator1 last1,
131 ForwardIterator2 first2);
132
9c73166 @wnbell more doxygen tweaking
wnbell authored
133 /*! \} // copying
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
134 */
135
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
136 } // end thrust
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
137
28f38b4 @jaredhoberock Add swap.h
jaredhoberock authored
138 #include <thrust/detail/swap.inl>
25342f7 @jaredhoberock Initial import of Komrade v0.9.
jaredhoberock authored
139
Something went wrong with that request. Please try again.