SpaceAnalyzer: Add a method to TreeNode to get a child node by name

This will make it easier to get to a tree node given a file path
This commit is contained in:
Arda Cinar 2022-12-13 11:16:55 +03:00 committed by Sam Atkins
parent 0d67e60559
commit ba33267132
Notes: sideshowbarker 2024-07-17 18:46:57 +09:00
2 changed files with 11 additions and 0 deletions

View file

@ -128,3 +128,13 @@ HashMap<int, int> TreeNode::populate_filesize_tree(Vector<MountInfo>& mounts, Fu
update_totals();
return error_accumulator;
}
Optional<TreeNode const&> TreeNode::child_with_name(DeprecatedString name) const
{
for (auto& child : *m_children) {
if (child.name() == name)
return child;
}
return {};
}

View file

@ -32,6 +32,7 @@ public:
return 0;
}
TreeNode const& child_at(size_t i) const { return m_children->at(i); }
Optional<TreeNode const&> child_with_name(DeprecatedString name) const;
void sort_children_by_area() const;
HashMap<int, int> populate_filesize_tree(Vector<MountInfo>& mounts, Function<void(size_t)> on_progress);