profile image

Nafis Ayaz

C++ Software Engineer

Pipeline Utilities

  • Pipeline is a small and effective functionalities, written in C++17. rovides many pipeline functions that can be used in both C++ standard libraries like std::list , std::vector , and also xperimental datastructures like xperimental::list_sm , xperimental::array_sm and so on. . It's fast and concise, increases industrial productivity.

    Objectives are:

  • Concise and yet readable
  • Memory management
  • Ability to handle Inter-process Commmunications
  • Productivity

  • Pipeline functions:

    #include<iostream> #include<xperimental/pipe.h++> int main(){   std::vector<int> int_v = { 12, 34, 33, 160, 45 };   xperimental::array<int> filtered_value = xperimental::from(v_int) | xperimental::filter([](auto x){      return x%3 == 0;   });   std::cout<< "Filtered values: ";   for(auto el: filtered_value){     std::cout<< el << " ";   }   xperimental::array<int> transformed_value = xperimental::from(v_int) | xperimental::filter([](auto x){               return x%3 == 0;       }) | xperimental::transform([](auto x){               return x*100;     });   std::cout<< "Transformed values: ";   for(auto el: transformed_value){     std::cout<< el << " ";   } }

    Output:

    Filtered values: 12 33 45
    Transformed values: 1200 3300 4500

    xperimental::from is applicable of any primitive data-types: int , float, std::string and xperimental datastructures like: xperimental::array of any data-type, xperimental::filter and xperimental::transform can take Lambda expression and Callable object that creates objects if there is no further pipe after that otherwise return data. Returned result is xperimental::array <int>

    #include<iostream> #include<xperimental/pipe.h++> int main(){   xperimental::variable<int> variable;   std::vector<int> int_v = { 12, 34, 33, 160, 45 };   xperimental::array<int> filtered_value = xperimental::from(v_int) | xperimental::filter([&variable](){      return variable * 4 == variable * variable * 4;   });   std::cout<< "=============== Filtered values: \n";   for(auto el: filtered_value){     std::cout<< el << " ";   } }

    Using xperimental::variable <int>, we can filter all those data, value of Left Handed Side is equal value Right Handed Side and returns xperimental::array<int> we can also implement it in std::find_if like this:

      xperimental::variable<int> variable;
      std::vector<int> int_v = { 12, 34, 33, 160, 45 };
      auto It = std::find_if(v_int.begin(), v_int.end(), variable * 4 == variable * variable * 4 );

    Using xperimental::variable<int>, can sort values and returns xperimental::array<int> we can also implement it in std::find_if like this:

    #include<iostream> #include<xperimental/pipe.h++> int main(){   std::vector<int> int_v = { 12, 34, 33, 160, 45 };   xperimental::variable<int> variable;   xperimental::array<int> sorted_value = xperimental::from(v_int) | xperimental::sort([&variable](auto x){      return variable < x;   });   std::cout<< "Sorted values: ";   for(auto el: sorted_value){     std::cout<< el << " ";   } }

    Output:

    Sorted values: 12 33 34 45 160

    xperimental::from is applicable of any primitive data-types: int , float, std::string and xperimental datastructures like: xperimental::array of any data-type, xperimental::filter and xperimental::transform can take Lambda expression and Callable object that creates objects if there is no further pipe after that otherwise return data. Returned result is xperimental::array <int>