Skip to content

Instantly share code, notes, and snippets.

@pgbarletta
Created April 7, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgbarletta/8bd7140a2a69bad0635cffcae0c5976f to your computer and use it in GitHub Desktop.
Save pgbarletta/8bd7140a2a69bad0635cffcae0c5976f to your computer and use it in GitHub Desktop.
// "called" is an object (functor) of the class "callback_for_boxes"
class callback_for_boxes {
public:
std::vector<size_t> *_id_vector_a, *_id_vector_b;
NA_Vector *_neighbors_a, *_neighbors_b;
callback_for_boxes(std::vector<size_t> &id_vector_a,
std::vector<size_t> &id_vector_b, NA_Vector &neighbors_a,
NA_Vector &neighbors_b)
: _id_vector_a(&id_vector_a), _id_vector_b(&id_vector_b),
_neighbors_a(&neighbors_a), _neighbors_b(&neighbors_b) {}
void operator()(const Box &a, const Box &b) {
// New boxes. Store their indices and their cells.
_id_vector_a->push_back(a.id());
_id_vector_b->push_back(b.id());
_neighbors_a->push_back(a.handle());
_neighbors_b->push_back(b.handle());
return;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment