# Transform algorithm based on list. : List « Data Structure « C++

Home
C++
 1 Bitset 2 Class 3 Console 4 Data Structure 5 Data Type 6 Deque 7 Development 8 File 9 Function 10 Generic 11 Language 12 List 13 Map Multimap 14 Overload 15 Pointer 16 Qt 17 Queue Stack 18 Set Multiset 19 STL Algorithms Binary search 20 STL Algorithms Heap 21 STL Algorithms Helper 22 STL Algorithms Iterator 23 STL Algorithms Merge 24 STL Algorithms Min Max 25 STL Algorithms Modifying sequence operations 26 STL Algorithms Non modifying sequence operations 27 STL Algorithms Sorting 28 STL Basics 29 String 30 Valarray 31 Vector
 C++ » Data Structure » List Screenshots
Transform algorithm based on list.
 ``` #include  #include  #include  using namespace std; double reciprocal(double i) {   return 1.0/i; } int main() {   list listObject;   int i;   for(i =1; i < 10; i++)       listObject.push_back((double)i);   cout << "Original contents of listObject:\n";   list::iterator p = listObject.begin();   while(p != listObject.end()) {     cout << *p << " ";     p++;   }   cout << endl;     // transform listObject   p = transform(listObject.begin(), listObject.end(), listObject.begin(), reciprocal);   cout << "Transformed contents of listObject:\n";   p = listObject.begin();   while(p != listObject.end()) {     cout << *p << " ";     p++;   }   return 0; }                    ```
Related examples in the same category
 1 List basics: push, begin, end pop 2 Elements can be put on the front or end of a list. 3 Define class and store in a list 4 An example of the transform algorithm. 5 Demonstrate merge() in list 6 Merging won't work if the lists aren't ordered. 7 Merge into descending order. 8 A list splicing example. 9 Demonstrate remove() in list 10 Demonstrate unique() in list 11 Using reverse() to create a palindrome tester. 12 Using a list to store mailing addresses. 13 Use ostream_iterator for string 14 Demonstrate advance() and distance() in list 15 Using an arrays as a container 16 Using a list: push_back, begin, end, size 17 Merge and splice lists. 18 Copy a list to a vector. 19 Push value in the list 20 Use a binary function object in list 'transform' 21 end() in list. 22 The difference between push_back() and push_front(). 23 Sort a list. 24 Merge two lists. 25 Store class objects in a list. 26 Demonstrate bind2nd(). 27 Create a reciprocal function object. 28 Understanding end() in List 29 Difference between push_back() and push_front() 30 Merging One List with Another 31 Storing Class Objects in a List 32 Traverse a List Using an Iterator 33 Demonstrate virtual functons: list interface