Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/algorithm/swap ranges"

From cppreference.com
< cpp‎ | algorithm
m (Text replace - "{{complex}}" to "===Complexity===")
m (Text replace - "{{eq fun}}" to "===Equivalent function===")
Line 27: Line 27:
  
 
<!-- ======== -->
 
<!-- ======== -->
{{eq fun}}
+
===Equivalent function===
 
{{eq fun cpp | 1=
 
{{eq fun cpp | 1=
 
template<class ForwardIterator1, class ForwardIterator2>
 
template<class ForwardIterator1, class ForwardIterator2>

Revision as of 17:55, 2 August 2011

Template:cpp/algorithm/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <algorithm>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
template< class ForwardIterator1, class ForwardIterator2 >

ForwardIterator2 swap_ranges( ForwardIterator1 first1,
                              ForwardIterator1 last1,

                              ForwardIterator2 first2 )
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

Exchanges elements between range [first1, last1) and another range starting at first2.

Contents

Parameters

first1, last1 - the first range of elements to swap
first2 - beginning of the second range of elements to swap

Return value

iterator to the element past the last element exchanged in the range beginning with first2.


Equivalent function

Template:eq fun cpp

Template:example cpp

Complexity

linear in the distance between first and last

See also

Template:cpp/algorithm/dcl list iter swapTemplate:cpp/algorithm/dcl list swap