mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 18:26:25 +00:00
Update unused filter() function
This commit is contained in:
@@ -1189,15 +1189,17 @@ T* dcast(const U*& u) {
|
|||||||
|
|
||||||
// @nb traverses nested collections
|
// @nb traverses nested collections
|
||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
taxonomy::collection::ptr filter(taxonomy::collection* collection, Fn fn) {
|
taxonomy::collection::ptr filter(taxonomy::collection::ptr collection, Fn fn) {
|
||||||
auto filtered = new taxonomy::collection;
|
auto filtered = taxonomy::make<taxonomy::collection>();
|
||||||
for (auto& child : collection->children) {
|
for (auto& child : collection->children) {
|
||||||
if (apply_predicate_to_collection(child, fn)) {
|
if (apply_predicate_to_collection(child, fn)) {
|
||||||
filtered->children.push_back(clone(child));
|
filtered->children.push_back(clone(child));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (filtered->children.empty()) {
|
if (filtered->children.empty()) {
|
||||||
|
#ifdef TAXONOMY_USE_NAKED_PTR
|
||||||
delete filtered;
|
delete filtered;
|
||||||
|
#endif
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return filtered;
|
return filtered;
|
||||||
|
|||||||
Reference in New Issue
Block a user