C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Algorithm swap_ranges()C++ Algorithm swap_ranges() exchanges the elements in the range [first1, last2) with the elements present in the range starting from first2. In short we can say that, swap_ranges() swaps the elements of two sequence, that is each element at a position in the first sequence is replaced by the element at the same position in the second sequence and vice-versa is also possible. Syntaxtemplate <class ForwardIterator1, class ForwardIterator2> ForwardIterator2 swap_ranges (ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); Parameterfirst1: A forward iterator pointing to the first position of the first range whose elements is to be swapped. last1: A forward iterator pointing to one past the final position of the first range whose elements are to be swapped. first2: A forward iterator pointing to the first position of the second range whose elements is to be swapped. Return valueswap_ranges() returns an iterator pointing to the end of the second range whose elements are to be exchanged. |