/usr/include/thrust/swap.h is in libthrust-dev 1.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | /*
* Copyright 2008-2012 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*! \file swap.h
* \brief Functions for swapping the value of elements
*/
#pragma once
#include <thrust/detail/config.h>
// empty Doxygen comment below so namespace thrust's documentation will be extracted
/*!
*/
namespace thrust
{
/*! \addtogroup utility
* \{
*/
/*! \addtogroup swap
* \{
*/
/*! \p swap assigns the contents of \c a to \c b and the
* contents of \c b to \c a. This is used as a primitive operation
* by many other algorithms.
*
* \param a The first value of interest. After completion,
* the value of b will be returned here.
* \param b The second value of interest. After completion,
* the value of a will be returned here.
*
* \tparam Assignable is a model of <a href="http://www.sgi.com/tech/stl/Assignable.html">Assignable</a>.
*
* The following code snippet demonstrates how to use \p swap to
* swap the contents of two variables.
*
* \code
* #include <thrust/swap.h>
* ...
* int x = 1;
* int y = 2;
* thrust::swap(x,h);
*
* // x == 2, y == 1
* \endcode
*/
template<typename Assignable1, typename Assignable2>
__host__ __device__
inline void swap(Assignable1 &a, Assignable2 &b);
/*! \} // swap
*/
/*! \} // utility
*/
/*! \addtogroup copying
* \{
*/
/*! \p swap_ranges swaps each of the elements in the range <tt>[first1, last1)</tt>
* with the corresponding element in the range <tt>[first2, first2 + (last1 - first1))</tt>.
* That is, for each integer \c n such that <tt>0 <= n < (last1 - first1)</tt>, it swaps
* <tt>*(first1 + n)</tt> and <tt>*(first2 + n)</tt>. The return value is
* <tt>first2 + (last1 - first1)</tt>.
*
* \param first1 The beginning of the first sequence to swap.
* \param last1 One position past the last element of the first sequence to swap.
* \param first2 The beginning of the second sequence to swap.
* \return An iterator pointing to one position past the last element of the second
* sequence to swap.
*
* \tparam ForwardIterator1 is a model of <a href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>,
* and \p ForwardIterator1's \c value_type must be convertible to \p ForwardIterator2's \c value_type.
* \tparam ForwardIterator2 is a model of <a href="http://www.sgi.com/tech/stl/ForwardIterator.html">Forward Iterator</a>,
* and \p ForwardIterator2's \c value_type must be convertible to \p ForwardIterator1's \c value_type.
*
* The following code snippet demonstrates how to use \p swap_ranges to
* swap the contents of two \c thrust::device_vectors.
*
* \code
* #include <thrust/swap.h>
* #include <thrust/device_vector.h>
* ...
* thrust::device_vector<int> v1(2), v2(2);
* v1[0] = 1;
* v1[1] = 2;
* v2[0] = 3;
* v2[1] = 4;
*
* thrust::swap_ranges(v1.begin(), v1.end(), v2.begin());
*
* // v1[0] == 3, v1[1] == 4, v2[0] == 1, v2[1] == 2
* \endcode
*
* \see http://www.sgi.com/tech/stl/swap_ranges.html
* \see \c swap
*/
template<typename ForwardIterator1,
typename ForwardIterator2>
ForwardIterator2 swap_ranges(ForwardIterator1 first1,
ForwardIterator1 last1,
ForwardIterator2 first2);
/*! \} // copying
*/
} // end thrust
#include <thrust/detail/swap.inl>
|