Signature | Description | Parameters |
---|---|---|
template<typename ... Ts> void multi_visit(Ts ... args); |
This is the most generalized visit function. It visits multiple columns with the corresponding function objects sequentially. Each function object is passed every single value of the given column along with its name and the corresponding index value. All functions objects must have this signaturebool (const IndexType &i, const char *name, T &col_value)If the function object returns false, the DataFrame will stop iterating at that point on that column.. NOTE: This method could be used to implement a pivot table. |
Ts: The list of types for columns in args args: A variable list of arguments consisting of std::pair(const char *name, &std::function<bool (const IndexType &, const char *, T &)>)Each pair represents a column name and the functor to run on it. NOTE: The second member of pair is a _pointer_ to the function or functor object |
std::cout << "\nTesting multi_visit() ..." << std::endl; MeanVisitor<int> ivisitor2; MeanVisitor<unsigned long> ulvisitor; MeanVisitor<double> dvisitor2; MeanVisitor<double> dvisitor22; dfx.multi_visit(std::make_pair("xint_col", &ivisitor2), std::make_pair("dbl_col", &dvisitor2), std::make_pair("dbl_col_2", &dvisitor22), std::make_pair("ul_col", &ulvisitor)); assert(ivisitor2.get_result() == 19); assert(fabs(dvisitor2.get_result() - 4.5696) < 0.0001); assert(fabs(dvisitor22.get_result() - 0.0264609) < 0.00001); assert(ulvisitor.get_result() == 123448); const MyDataFrame dfx_c = dfx; dfx_c.multi_visit(std::make_pair("xint_col", &ivisitor2), std::make_pair("dbl_col", &dvisitor2), std::make_pair("dbl_col_2", &dvisitor22), std::make_pair("ul_col", &ulvisitor)); assert(ivisitor2.get_result() == 19); assert(fabs(dvisitor2.get_result() - 4.5696) < 0.0001); assert(fabs(dvisitor22.get_result() - 0.0264609) < 0.00001); assert(ulvisitor.get_result() == 123448);