58 if (!_allNode.empty())
64 _allNode.push_back(node);
68 Node* node_parent =
Get(parent);
74 Node* node =
new Node(v, node_parent);
75 _allNode.push_back(node);
76 node_parent->
_child.push_back(node);
84 for (
Node* node : _allNode)
101 s.push(_allNode.front());
105 Node* node_this = s.top();
110 auto& c = node_this->
_child;
111 for (
auto iter = c.rbegin(); iter != c.rend(); ++iter)
120 auto begin() {
return _allNode.begin(); }
121 auto end() {
return _allNode.end(); }
125 for (
Node* node : _allNode)
131 std::list<Node*> _allNode;
void ForEach(F func)
遍历,保证父节点先遍历
Node * Get(T v)
查找,失败返回nullptr
auto begin()
标准库迭代方法不保证父节点先遍历
Node * Add(const T &v, const T &parent)
添加,parent为nullptr时,为添加根节点
void log_err0(std::string_view str, const std::source_location location=std::source_location::current())
std::vector< Node * > _child
Node(const T &v, Node *parent)