|
edelib
2.0.0
|
Functions | |
| template<typename T , typename F > | |
| unsigned int | filter (const F &func, const T &container, T &ret) |
| template<typename T , typename F > | |
| void | map (F &func, const T &container, T &ret) |
| template<typename T , typename R , typename F > | |
| void | reduce (F &func, const T &container, R &ret) |
| template<typename T , typename F > | |
| void | for_each (const F &func, const T &container) |
| template<typename T , typename F > | |
| void | for_each (const F &func, const T &container, void *p) |
| unsigned int edelib::filter | ( | const F & | func, |
| const T & | container, | ||
| T & | ret | ||
| ) |
Filter given container by calling func on each element. If func returns true for given element, it will be copied to other list.
| void edelib::for_each | ( | const F & | func, |
| const T & | container | ||
| ) |
Traverse container calling func on each element. Returns nothing.
| void edelib::for_each | ( | const F & | func, |
| const T & | container, | ||
| void * | p | ||
| ) |
Same as above for_each, but with additional void* parameter that is given to function as second parameter (function is called as func(val, void*)
| void edelib::map | ( | F & | func, |
| const T & | container, | ||
| T & | ret | ||
| ) |
Apply func on each element of given container and add it to ret container.
| void edelib::reduce | ( | F & | func, |
| const T & | container, | ||
| R & | ret | ||
| ) |
Reduce all elements from container using func as function. The best example of this is to sum all elements, like:
int sum(int a, int b) { return a + b; } int ret; list <int> lst; // [1,2,3,4,5] reduce(sum, lst, ret); // result will be in form 1 + 2 + 3 + 4 + 5
1.7.6.1