TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C++ algorithm transform() function

C++ algorithm transform() function with c++ tutorial for beginners and professionals with examples on adjacent_find(),any_of(), copy(), copy_if(), count(), count_if(), equal(), find(), find_end(), find_first_of(), find_if(), find_if_not(), for_each() etc.

<< Back to CPP

C++ Algorithm transform()

C++ Algorithm transform() function is used in two different ways:

1.unary operation:- This method performs unary operation op on the elements in range [first1, last1] and stores the result in range starting from result.

This transform() applies a function to each element of a range:

C++ Algorithm transform Function

2.Binary operation:- This method performs binary operation binary_op on the elements in range [first1, last1] with the elements in the range starting with iterator first2 and stores the result in range starting from result.

This transform() takes two 2 ranges and applies a function that takes 2 parameters, on each couple of elements from the input ranges:

C++ Algorithm transform Function

Syntax

unary operation(1)

template <class InputIterator, class OutputIterator, class UnaryOperation>
OutputIterator transform (InputIterator first1, InputIterator last1,
OutputIterator result, UnaryOperation op);

Binary operation(2)

template <class InputIterator1, class InputIterator2,
class OutputIterator, class BinaryOperation>
OutputIterator transform (InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, OutputIterator result,
BinaryOperation binary_op);

Parameter

first1: An input iterator pointing the position of the first element of the first range to be operated on.

last1: An iterator pointing the position one past the final element of the first range to be operated on.

first2: Input iterator pointing to the first element in the second range to be operated on.

result: An output iterator to the initial position of the range where the operation results are stored.

op: Unary function applied to each element of the range.

binary_op: Binary function that two elements passed as its arguments.

Return value

transform() returns an iterator pointing to the end of the transformed range.

Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf