THUKEG/saedb — pull request #48 by neozhangthe1 (2013-04-16 07:20:58+00:00)
Title: Map reduce context

for mabo:
context in map reduce function
use case:

```cpp
struct alpha_beta_type {
int alpha;
int beta;

alpha_beta_type() :
alpha(-1), beta(-1) {
}
alpha_beta_type(int alpha_beta, bool inside) {
alpha = -1;
beta = -1;
if (inside) {
beta = alpha_beta;
} else {
alpha = alpha_beta;
}
}

alpha_beta_type& operator+=(const alpha_beta_type& other) {
if (other.beta > -1) {
if (beta > -1) {
beta = std::min(beta, other.beta);
} else {
beta = other.beta;
}
} else if (other.alpha > -1) {
if (alpha > -1) {
alpha = std::max(alpha, other.alpha);
} else {
alpha = other.alpha;
}
}
std::cout << " alpha:" << alpha << " beta:" << beta << endl;
return *this;
}

static alpha_beta_type aggregator(icontext_type& context, graph_type::vertex_type& vertex) {
std::cout << "id:" << vertex.id() << " inside: " << vertex.data().inside
<< " alpha:" << vertex.data().alpha_beta << std::endl;
return alpha_beta_type(vertex.data().alpha_beta, vertex.data().inside);
}
};
```