mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 06:57:45 +00:00
SpaceAnalyzer: Remove an unnecessary level of inheritance
The TreeMapNode and TreeMap structs inside TreeMapWidget.h both had single implementers, TreeNode and Tree inside main.cpp. The indirection was removed and the new structures were moved to their own file
This commit is contained in:
parent
f476b827de
commit
8ba37872e9
6 changed files with 84 additions and 74 deletions
45
Userland/Applications/SpaceAnalyzer/Tree.h
Normal file
45
Userland/Applications/SpaceAnalyzer/Tree.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
struct TreeNode final {
|
||||
TreeNode(DeprecatedString name)
|
||||
: m_name(move(name)) {};
|
||||
|
||||
DeprecatedString name() const { return m_name; }
|
||||
i64 area() const { return m_area; }
|
||||
size_t num_children() const
|
||||
{
|
||||
if (m_children) {
|
||||
return m_children->size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
TreeNode const& child_at(size_t i) const { return m_children->at(i); }
|
||||
void sort_children_by_area() const;
|
||||
|
||||
DeprecatedString m_name;
|
||||
i64 m_area { 0 };
|
||||
OwnPtr<Vector<TreeNode>> m_children;
|
||||
};
|
||||
|
||||
struct Tree : public RefCounted<Tree> {
|
||||
Tree(DeprecatedString root_name)
|
||||
: m_root(move(root_name)) {};
|
||||
~Tree() {};
|
||||
TreeNode m_root;
|
||||
TreeNode const& root() const
|
||||
{
|
||||
return m_root;
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue