1#line 1 "D:/Jenkins/workspace/EMS/ECG/ufe/full/ufe-full-python3.13-windows/ufe/include/trie.imp.h"
26 : fComponent(component), fParent(), fChildren(), fHasData(false),
38 UFE_ASSERT_MSG(fChildren.find(child->component()) == fChildren.end(),
39 "Child trie node already exists.");
41 fChildren[child->component()] = child;
44 child->setParent(this->shared_from_this());
51 fChildren.erase(child->component());
53 child->setParent(
Ptr());
68 return fParent.lock();
74 return fChildren.find(component) != fChildren.end();
80 typename Children::const_iterator
const found = fChildren.find(component);
81 return found == fChildren.end() ?
Ptr() : found->second;
87 std::vector<PathComponent> ret;
88 ret.reserve(fChildren.size());
89 for (
auto c : fChildren)
91 ret.emplace_back(c.first);
99 std::size_t sz = size();
108 if ( hasData() || 0 == sz) {
121 typename Children::const_iterator
const next = fChildren.begin();
122 return next->second->closestCommonAncestor(depth);
128 return fChildren.size();
134 return std::accumulate(
135 fChildren.begin(), fChildren.end(), std::size_t(1),
136 [](std::size_t treeSize,
const typename Children::value_type& child) {
137 return treeSize+child.second->treeSize();
157 "Cannot rename child trie node, not found in parent.");
158 auto self = this->shared_from_this();
161 fComponent = component;
168 auto oldParent = parent();
169 if (newParent == oldParent)
171 UFE_ASSERT_MSG(!newParent->contains(component),
"Cannot reparent child trie node, new component already exists in new parent.");
172 UFE_ASSERT_MSG(oldParent->contains(fComponent),
"Cannot reparent child trie node, not found in parent.");
173 auto self = this->shared_from_this();
174 oldParent->remove(self);
175 fComponent = component;
176 newParent->add(self);
221 rhs.fRoot = std::make_shared< TrieNode<T> >();
227 fRoot = std::move(rhs.fRoot);
228 rhs.fRoot = std::make_shared< TrieNode<T> >();
246 child = std::make_shared< TrieNode<T> >(c);
247 trieNode->
add(child);
270 if (trieNode && trieNode->
hasData())
293 return bool(find(
path));
297template<
bool INCLUDE_ANCESTOR>
304 if (ancestorPath.
empty()) {
325 return INCLUDE_ANCESTOR ? true : !trieNode->
empty();
331 return containsDescendantHelper<false>(ancestorPath);
337 return containsDescendantHelper<true>(ancestorPath);
341template<
bool INCLUDE_DESCENDANT>
348 if (descendantPath.
empty()) {
355 auto pathEndIt = descendantPath.
cend();
359 if (!INCLUDE_DESCENDANT) {
360 pathEndIt = std::prev(pathEndIt);
362 for (
auto pathIt = descendantPath.
cbegin(); pathIt != pathEndIt; ++pathIt) {
385 return containsAncestorHelper<false>(descendantPath);
391 return containsAncestorHelper<true>(descendantPath);
397 return root()->closestCommonAncestor(-1);
423 while (child->
empty() && !child->
hasData() && child != root()) {
439 trieNode->
move(newPath.
back(), newParentNode);
440 cleanUpNode(oldParentNode);
454 return root()->treeSize();
460 return root()->empty();
Constant string representation with fixed space and O(1) comparison.
Identify an object or 3D path in the scene.
PathComponent back() const
Components::const_iterator cbegin() const
Components::const_iterator cend() const
Node for Universal Front End trie.
bool containsAncestor(const Path &path) const
TrieNode< T >::Ptr add(const Path &path, const T &data)
TrieNode< T >::Ptr node(const Path &path) const
bool containsDescendant(const Path &path) const
bool containsAncestorInclusive(const Path &path) const
TrieNode< T >::Ptr find(const Path &path) const
Trie & operator=(const Trie &)=delete
TrieNode< T >::Ptr createNode(const Path &path)
bool containsDescendantHelper(const Path &path) const
int closestCommonAncestor() const
void cleanUpNode(const typename TrieNode< T >::Ptr &node)
bool contains(const Path &path) const
TrieNode< T >::Ptr move(const Path &oldPath, const Path &newPath)
TrieNode< T >::Ptr root() const
TrieNode< T >::Ptr remove(const Path &)
bool containsAncestorHelper(const Path &path) const
bool containsDescendantInclusive(const Path &path) const
void remove(const Ptr &child)
void add(const Ptr &child)
void rename(const PathComponent &component)
std::shared_ptr< TrieNode > Ptr
void setParent(Ptr parent)
void move(const PathComponent &component, const Ptr &newParent)
void setData(const T &data)
std::size_t treeSize() const
std::weak_ptr< TrieNode > ParentPtr
int closestCommonAncestor(int depth) const
std::vector< PathComponent > childrenComponents() const
Ptr operator[](const PathComponent &child) const
PathComponent component() const
bool contains(const PathComponent &child) const
std::shared_ptr< ObservableSelection > Ptr
Path path(const std::string &pathString)
#define UFE_ASSERT_MSG(EXPR, MSG)
#define UFE_ASSERT_COMPILED(CODE)