1 #line 1 "S:/jenkins/workspace/ufe-full-windows/ufe/include/trie.imp.h" 27 : fComponent(component), fParent(), fChildren(), fHasData(false),
39 UFE_ASSERT_MSG(fChildren.find(child->component()) == fChildren.end(),
40 "Child trie node already exists.");
42 fChildren[child->component()] = child;
45 child->setParent(this->shared_from_this());
52 fChildren.erase(child->component());
54 child->setParent(
Ptr());
69 return fParent.lock();
75 return fChildren.find(component) != fChildren.end();
81 typename Children::const_iterator
const found = fChildren.find(component);
82 return found == fChildren.end() ?
Ptr() : found->second;
88 std::size_t sz = size();
97 if ( hasData() || 0 == sz) {
110 typename Children::const_iterator
const next = fChildren.begin();
111 return next->second->closestCommonAncestor(depth);
117 return fChildren.size();
123 return std::accumulate(
124 fChildren.begin(), fChildren.end(), std::size_t(1),
125 [](std::size_t treeSize,
const typename Children::value_type& child) {
126 return treeSize+child.second->treeSize();
146 "Cannot rename child trie node, not found in parent.");
147 auto self = this->shared_from_this();
150 fComponent = component;
196 rhs.fRoot = std::make_shared< TrieNode<T> >();
202 fRoot = std::move(rhs.fRoot);
203 rhs.fRoot = std::make_shared< TrieNode<T> >();
221 child = std::make_shared< TrieNode<T> >(c);
222 trieNode->
add(child);
264 return bool(find(
path));
295 return !trieNode->
empty();
305 if (descendantPath.
empty()) {
311 auto parentPath = descendantPath.
pop();
337 return root()->closestCommonAncestor(-1);
355 while (child->
empty() && !child->
hasData() && child != root()) {
373 return root()->treeSize();
void setData(const T &data)
TrieNode< T >::Ptr node(const Path &path) const
std::size_t treeSize() const
bool containsAncestor(const Path &path) const
void remove(const Ptr &child)
std::shared_ptr< ObservableSelection > Ptr
Constant string representation with fixed space and O(1) comparison.
Trie & operator=(const Trie &)=delete
bool contains(const Path &path) const
void setParent(Ptr parent)
PathComponent component() const
Node for Universal Front End trie.
#define UFE_ASSERT_MSG(EXPR, MSG)
bool containsDescendant(const Path &path) const
void rename(const PathComponent &component)
void add(const Ptr &child)
Identify an object or 3D path in the scene.
int closestCommonAncestor() const
bool contains(const PathComponent &child) const
Ptr operator[](const PathComponent &child) const
TrieNode< T >::Ptr remove(const Path &)
TrieNode< T >::Ptr root() const
TrieNode< T >::Ptr find(const Path &path) const
std::weak_ptr< TrieNode > ParentPtr
int closestCommonAncestor(int depth) const
std::shared_ptr< TrieNode > Ptr
Path path(const std::string &pathString)
#define UFE_ASSERT_COMPILED(CODE)
TrieNode< T >::Ptr add(const Path &path, const T &data)