Node<T> *DoubleLinkedList<T>::nodeFilter(Node<T> *node, std::function<bool(T)> cls) { if (node == 0) { return 0; } else if (cls(node->value)) { Node<T> *tmp = new Node<T>(); tmp->value = node->value; tmp->next = nodeFilter(node->next, cls); return tmp; } else { return nodeFilter(node->next, cls); } }
void MatchScoringMapPreparer::prepMap(OsmMapPtr map, const bool removeNodes) { // if an element has a uuid, but no REF1/REF2 tag then create a REF tag with the uuid. The // 1/2 is determined by the unknown status. ConvertUuidToRefVisitor convertUuidToRef; map->visitRw(convertUuidToRef); // #5891 if the feature is marked as todo then there is no need to conflate & evaluate it. shared_ptr<TagCriterion> isTodo(new TagCriterion("REF2", "todo")); RemoveElementsVisitor remover(isTodo); remover.setRecursive(true); map->visitRw(remover); // add a uuid to all elements with a REF tag. HasTagCriterion criterion("REF1", "REF2", "REVIEW"); AddUuidVisitor uuid("uuid"); FilteredVisitor v(criterion, uuid); map->visitRw(v); if (removeNodes) { // remove all REF1/REF2 tags from the nodes. RemoveTagVisitor removeRef("REF1", "REF2"); IsNodeFilter nodeFilter(Filter::KeepMatches); FilteredVisitor removeRefV(nodeFilter, removeRef); map->visitRw(removeRefV); } //MapCleaner().apply(map); }
void TarjanHD::run() { _T.clear(); NodeNodeMap mapToOrgG(_orgG, lemon::INVALID); for (NodeIt v(_orgG); v != lemon::INVALID; ++v) { mapToOrgG[v] = v; } ArcList arcs; for (ArcIt a(_orgG); a != lemon::INVALID; ++a) { arcs.push_back(a); } // sort by weight arcs.sort(Comparison(_orgW)); BoolArcMap arcFilter(_orgG, true); BoolNodeMap nodeFilter(_orgG, true); NodeNodeMap G2T(_orgG, lemon::INVALID); SubDigraph subG(_orgG, nodeFilter, arcFilter); _root = hd(_orgG, _orgW, subG, mapToOrgG, G2T, arcs, 0); fixTree(_root); }
DoubleLinkedList<T> *DoubleLinkedList<T>::filter(std::function<bool(T)> cls) { return new DoubleLinkedList(nodeFilter(this->first, cls)); }