C++ std::move for list














































C++ std::move for list



/**C++ std::move for list**/ /**This algorithm is about to move the elements for a given range of a list. move() is define for 'algorithm' headerfile. Function Template: move(first_iterator, last_iterator, output_iterator); first_iterator = it indicates initial pointer of 1st list; last_iterator = it indicates last pointer of 1st list; output_iterator = it indicates a address after that elements of 2nd list will be moved by elements of 1st list; **/ Algorithm: #include<bits/stdc++.h> #include<algorithm> #include<list> using namespace std; int main () { list<int>list1,list2; for(int i=1;i<=10;i++) list1.push_back(i); for(int i=0;i<10;i++) list2.push_back(7); list<int>:: iterator it; //Elements first list before calling move() function; cout << "Elements of first list before calling move() function:" << endl; for(it = list1.begin(); it != list1.end(); ++it) cout << *it << " "; cout << endl; //Elements second list before calling move() function; cout << "Elements second list before calling move() function:" << endl; for(it = list2.begin(); it != list2.end(); ++it) cout << *it << " "; cout << endl; //Calling move() function; move(list1.begin(),list1.end(),list2.begin()); //Elements of second list after calling move() function; cout << "Elements of second array after calling move() function:" << endl; for(it = list2.begin(); it != list2.end(); ++it) cout << *it << " "; return 0; } /** Output: Elements of first list before calling move() function: 1 2 3 4 5 6 7 8 9 10 Elements second list before calling move() function: 7 7 7 7 7 7 7 7 7 7 Elements of second list after calling move() function: 1 2 3 4 5 6 7 8 9 10 **/


More Articles of Ezaz Hossain Sardar:

Name Views Likes
Python Program to Find the first Common Element between the 2 given Linked Lists 254 20
C++ std::valarray_function_name 320 23
C++ std::typeindex_function_name 220 14
C++ std::condition_variable 299 16
C++ mutex mutex_function_name 299 24
C++ std:: 234 20
C++ std::is_trivially_default_constructible 295 20
C++ std::is_trivially_copy_constructible 302 29
C++ std::is_signed 294 25
C++ std::is_scalar 246 15
C++ std::is_same 324 22
C++ std::is_rvalue_reference 269 15
C++ std::is_reference 212 17
C++ std::is_object 257 15
C++ std::is_nothrow_destructible 334 26
C++ std::is_nothrow_constructible 300 22
C++ std::is_member_pointer 240 16
C++ std::is_member_function_pointer 263 19
C++ std::is_literal_type 305 26
C++ std::is_fundamental 262 16
C++ std::is_compound 267 20
C++ std::move for list 298 29
C++ std::move for array 287 22
C++ std::move 274 20
C++ std::replace for array 853 17
C++ std::replace 296 20
C++ std::replace_if 296 22
C++ std::minmax 325 27
C++ std::minmax_element 299 11
C++ std::remove 241 12
C++ std::remove_if 266 18
C++ std::replace_copy 254 20
C++ std::replace_copy_if 234 11
C++ std::remove_copy 272 19
C++ program to find get level of a node in binary tree using recursion 274 28
C++ program to find size of a tree without using recursion 202 14
C++ program to find height of a tree without using recursion 212 17
C++ program to find diameter of a binary tree in O(n) 270 23
C++ program to find diameter of a binary tree 245 13
C++ program to find height of a tree using recursion 215 17
C++ program to count non-leaf nodes in a binary tree using recursion 320 19
C++ program to count leaf nodes in a binary tree using recursion 672 13
C++ program to find sum of all leaf nodes of binary tree 251 21
C++ program to find sum of all the parent nodes having child node x 402 23
C++ program to print path from root to a given node in a binary tree 245 16
C++ program to find distance from root to given node in a binary tree 264 18

Comments