edelib 2.1.0
Functional handling for edelib::List and similar constructs

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)
 

Detailed Description

Function Documentation

◆ filter()

template<typename T , typename F >
unsigned int 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.

References edelib::filter().

Referenced by edelib::filter().

◆ for_each() [1/2]

template<typename T , typename F >
void for_each ( const F & func,
const T & container )

Traverse container calling func on each element. Returns nothing.

References edelib::for_each().

Referenced by edelib::for_each(), and edelib::for_each().

◆ for_each() [2/2]

template<typename T , typename F >
void 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*)

References edelib::for_each().

◆ map()

template<typename T , typename F >
void map ( F & func,
const T & container,
T & ret )

Apply func on each element of given container and add it to ret container.

References edelib::map().

Referenced by edelib::map().

◆ reduce()

template<typename T , typename R , typename F >
void 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
void reduce(F &func, const T &container, R &ret)
Definition Functional.h:79

References edelib::reduce().

Referenced by edelib::reduce().