21 void filter (
const AIPtr& entity)
override;
24 inline void Intersection::filter (
const AIPtr& entity) {
25 FilteredEntities& filtered = getFilteredEntities(entity);
27 const FilteredEntities alreadyFiltered = filtered;
31 std::vector<FilteredEntities> filteredArray(_filters.size());
34 for (
auto& f : _filters) {
36 filteredArray[n++] = filtered;
37 max = std::max(filtered.size(), max);
42 for (
size_t i = 0; i < filteredArray.size(); ++i) {
43 std::sort(filteredArray[i].begin(), filteredArray[i].end());
46 FilteredEntities result(max);
47 std::set_intersection(
48 filteredArray[0].begin(), filteredArray[0].end(),
49 filteredArray[1].begin(), filteredArray[1].end(),
50 std::back_inserter(result));
52 if (filteredArray.size() >= 2) {
53 FilteredEntities buffer(max);
54 for (
size_t i = 2; i < filteredArray.size(); ++i) {
56 std::sort(result.begin(), result.end());
57 std::set_intersection(
58 result.begin(), result.end(),
59 filteredArray[i].begin(), filteredArray[i].end(),
60 std::back_inserter(buffer));
61 std::swap(result, buffer);
65 filtered.reserve(alreadyFiltered.size() + max);
66 for (
auto& e : alreadyFiltered) {
67 filtered.push_back(e);
69 for (
auto& e : result) {
70 filtered.push_back(e);
This filter performs an intersection between several filter results.
Definition: Intersection.h:16