C++: Algorithm:: transformation of an array.

Objectives :

  • What is algorithm:transformation ?:
    • A member of STL.
    • It is a modifier or a transformer as it has been named. : Apply an operation to each element in an input sequence of a source, store the data and sequence in a buffer and transform the target source in a procedural way.
    • This allows the developer to treat target sequence, with a source sequence; the treatment could be addition, multiplication or division, all depends what you intend to do with 
  • File Name : myAlgo_transform1.cpp
    • Used : ostream_iterator< int > output( cout, " " );
      transform (Vint1.begin(), Vint1.end(), Vstat.begin(), Vint1.begin(), add);
    •  transform function is supported by STL:Algorithm, where values in an array can be altered by calling a function like "add".


Step: 1 Create a project and a source file. with eclipse and Quincy application.

Step: 2 Edit and save Source file



Step: 3 Runtime Views:


Quincy Runtime views.

Step: Brief Discussion: The function "transform" can impose an operation on an array. The data of "Vstast" array was added to range Vint1, with an index starting from 0 to 10. 

transform (Vint1.begin(), Vint1.end(), Vstat.begin(), Vint1.begin(), add);