Skip to content

Commit

Permalink
Format PathTree.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
xorz57 committed Apr 2, 2024
1 parent 8262a40 commit eb3f150
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions include/PathTree/PathTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ class PathTree {
while (std::getline(iss, name, '/')) {
if (!name.empty()) {
auto it = std::find_if(
current->children.begin(),
current->children.end(),
[&](const std::shared_ptr<Node> &child){ return child->name == name; }
);
current->children.begin(),
current->children.end(),
[&](const std::shared_ptr<Node> &child) { return child->name == name; });
if (it == current->children.end()) {
auto component = std::make_shared<Node>(name);
current->children.push_back(component);
Expand All @@ -92,10 +91,9 @@ class PathTree {
while (std::getline(iss, name, '/')) {
if (!name.empty()) {
auto it = std::find_if(
current->children.begin(),
current->children.end(),
[&](const std::shared_ptr<Node> &child){ return child->name == name; }
);
current->children.begin(),
current->children.end(),
[&](const std::shared_ptr<Node> &child) { return child->name == name; });
if (it != current->children.end()) {
parent = current;
current = *it;
Expand All @@ -105,12 +103,11 @@ class PathTree {
}
}
parent->children.erase(
std::remove_if(
parent->children.begin(),
parent->children.end(),
[&](const std::shared_ptr<Node> &child){ return child->name == current->name; }),
parent->children.end()
);
std::remove_if(
parent->children.begin(),
parent->children.end(),
[&](const std::shared_ptr<Node> &child) { return child->name == current->name; }),
parent->children.end());
}

bool containsPathHelper(const std::shared_ptr<Node> &root, const std::string &path) const {
Expand All @@ -120,10 +117,9 @@ class PathTree {
while (std::getline(iss, name, '/')) {
if (!name.empty()) {
auto it = std::find_if(
current->children.begin(),
current->children.end(),
[&](const std::shared_ptr<Node> &child){ return child->name == name; }
);
current->children.begin(),
current->children.end(),
[&](const std::shared_ptr<Node> &child) { return child->name == name; });
if (it == current->children.end()) {
return false;
} else {
Expand All @@ -143,7 +139,7 @@ class PathTree {
std::cout << " ";
}
std::cout << root->name << std::endl;
for (const std::shared_ptr<Node> &child : root->children) {
for (const std::shared_ptr<Node> &child: root->children) {
show(child, depth + 1);
}
}
Expand Down

0 comments on commit eb3f150

Please sign in to comment.