[DEV] add some fucntions on tree
This commit is contained in:
parent
3101490a3d
commit
8e3c9b253d
@ -208,7 +208,7 @@ namespace etk {
|
||||
};
|
||||
#endif
|
||||
private:
|
||||
etk::Vector<const ememory::SharedPtr<etk::TreeNode<ETK_TREENODE_TYPE>>> m_data;
|
||||
etk::Vector<ememory::SharedPtr<etk::TreeNode<ETK_TREENODE_TYPE>>> m_data;
|
||||
public:
|
||||
FlatTree() {
|
||||
|
||||
@ -217,6 +217,27 @@ namespace etk {
|
||||
m_data.clear();
|
||||
append(_root);
|
||||
}
|
||||
size_t size() const {
|
||||
return m_data.size();
|
||||
}
|
||||
auto begin() const {
|
||||
return m_data.begin();
|
||||
}
|
||||
auto begin() {
|
||||
return m_data.begin();
|
||||
}
|
||||
auto end() const {
|
||||
return m_data.end();
|
||||
}
|
||||
auto end() {
|
||||
return m_data.end();
|
||||
}
|
||||
auto operator[] (size_t _pos) {
|
||||
return m_data[_pos];
|
||||
}
|
||||
auto operator[] (size_t _pos) const {
|
||||
return m_data[_pos];
|
||||
}
|
||||
private:
|
||||
void append(const ememory::SharedPtr<etk::TreeNode<ETK_TREENODE_TYPE>>& _node) {
|
||||
if (_node == null) {
|
||||
|
@ -124,6 +124,13 @@ namespace etk {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
size_t countToRoot() {
|
||||
auto parent = m_parent.lock();
|
||||
if (parent == null) {
|
||||
return 0;
|
||||
}
|
||||
return parent->countToRoot() + 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user