|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Low-level prefix tree node for storing character sequences. More...
#include <prefix-tree.H>
Classes | |
| class | Clone_Target_Rollback |
| Restore a clone target if appending cloned children fails. More... | |
| class | Detached_Subtree_Guard |
| Own a detached subtree until it is committed elsewhere. More... | |
| class | Pending_Path_Guard |
| Own standalone nodes until an insertion path is committed. More... | |
Public Member Functions | |
| Cnode (const char c) noexcept | |
| Construct a node with the given character. | |
| char | symbol () const noexcept |
| Return the character stored in this node. | |
| DynList< Cnode * > | children () const |
| Return a list of all child nodes. | |
| std::string | to_str () const |
| Convert the subtree to a string representation. | |
| bool | is_end_word () const noexcept |
| Check if this node marks the end of a word. | |
| void | mark_end_word () |
| Mark this node as the end of a word. | |
| Cnode * | search_child (const char c) noexcept |
| Search for a mutable child with the given character. | |
| const Cnode * | search_child (const char c) const noexcept |
| Search for a const child with the given character. | |
| Cnode * | greater_child (const char c) noexcept |
| Find the first mutable child with a character greater than c. | |
| const Cnode * | greater_child (const char c) const noexcept |
| Find the first const child with a character greater than c. | |
| std::tuple< Cnode *, const char * > | search_prefix (const char *prefix) noexcept |
| Search for a prefix in the mutable tree. | |
| std::tuple< const Cnode *, const char * > | search_prefix (const char *prefix) const noexcept |
| Search for a prefix in the const tree. | |
| const Cnode * | search_word (const char *word) const noexcept |
| Search for a complete word in the tree. | |
| bool | contains (const std::string &word) const noexcept |
| Check if a word exists in the tree. | |
| size_t | count () const noexcept |
| Count total words stored in this subtree. | |
| DynArray< std::string > | words_with_prefix (const std::string &prefix, const size_t max_word_length=2048) const |
| Get all words starting with a given prefix. | |
| Cnode * | insert_child (Cnode *child) |
| Insert a child node in sorted order. | |
| bool | insert_word (const std::string &word) |
| Insert a word into the tree. | |
| void | destroy () noexcept |
| Destroy all children of this node. | |
| DynArray< std::string > | words (size_t max_word_length=2048) const |
| Get all words stored in this subtree. | |
| void | print_words (const size_t max_word_length=2048) const |
| Print all words to stdout. | |
| Cnode * | clone () const |
| Create a deep copy of this subtree. | |
Public Member Functions inherited from Aleph::Tree_Node< char > | |
| char & | get_key () noexcept |
| Returns a modifiable reference to the node contents. | |
| constexpr const char & | get_key () const noexcept |
| char & | get_data () noexcept |
| Returns a modifiable reference to the node contents. | |
| constexpr const char & | get_data () const noexcept |
| Dlink * | get_child_list () noexcept |
| Returns the embedded child-list link. | |
| Dlink * | get_sibling_list () noexcept |
| Returns the embedded sibling-list link. | |
| constexpr bool | is_root () const noexcept |
| Returns true if this is the root of the general tree. | |
| constexpr bool | is_leaf () const noexcept |
| Returns true if this is a leaf node. | |
| constexpr bool | is_leftmost () const noexcept |
| Returns true if this is the leftmost node among its siblings. | |
| constexpr bool | is_rightmost () const noexcept |
| Returns true if this is the rightmost node among its siblings. | |
| void | set_is_root (bool value) noexcept |
| Sets the root flag. | |
| void | set_is_leaf (bool value) noexcept |
| Sets the leaf flag. | |
| void | set_is_leftmost (bool value) noexcept |
| Sets the leftmost-sibling flag. | |
| void | set_is_rightmost (bool value) noexcept |
| Sets the rightmost-sibling flag. | |
| Tree_Node ()=default | |
| Empty constructor (undefined key). | |
| Tree_Node (const char &d) | |
| Constructor with data value __data. | |
| Tree_Node (char &&d) | |
| Tree_Node * | get_left_sibling () const noexcept |
| Returns the left sibling of this. | |
| Tree_Node * | get_right_sibling () const noexcept |
| Returns the right sibling of this. | |
| Tree_Node * | get_left_child () const noexcept |
| Returns the leftmost child of this. | |
| Tree_Node * | get_right_child () const noexcept |
| Returns the rightmost child of this. | |
| Tree_Node * | get_child (const size_t i) const noexcept |
| Returns the i-th child of this. | |
| Tree_Node * | get_parent () const noexcept |
| Returns the parent of this. | |
| void | insert_right_sibling (Tree_Node *p) noexcept |
| Inserts p to the right of this node. | |
| void | insert_left_sibling (Tree_Node *p) |
| Inserts p as the left sibling of this. | |
| void | insert_leftmost_child (Tree_Node *p) noexcept |
| Inserts p as the leftmost child of this. | |
| void | insert_rightmost_child (Tree_Node *p) noexcept |
| Inserts p as the rightmost child of this. | |
| Tree_Node * | join (Tree_Node *tree) |
join tree as subtree of root this | |
| void | insert_tree_to_right (Tree_Node *tree) |
Insert tree to the right of this | |
| Tree_Node * | get_left_tree () const noexcept |
| Returns the tree to the left of this. | |
| Tree_Node * | get_right_tree () const noexcept |
| Returns the tree to the right of this. | |
| Tree_Node * | get_last_tree () const |
| Returns the rightmost tree of the forest containing this. | |
| Container< Tree_Node * > | trees () const |
| Return a list with all trees belonging to the forest. | |
| void | for_each_child (Operation &op) const |
| Visits each child of this and executes the operation on the child node. | |
| void | for_each_child (Operation &&op=Operation()) const |
| Container< Tree_Node * > | children_nodes () const |
| Returns a list with the child nodes of this. | |
| Container< char > | children () const |
| Returns a list with the contents of the children of this. | |
| bool | traverse (Operation op) |
| Preorder traversal over all nodes executing op. | |
| bool | traverse (Operation op) const |
| bool | level_traverse (Op op) |
| bool | level_traverse (Op op) const |
| Children_Iterator | children_it () const |
| Iterator | get_it () const |
| iterator | begin () noexcept |
| const_iterator | begin () const noexcept |
| iterator | end () noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cbegin () const noexcept |
| const_iterator | cbegin () noexcept |
| const_iterator | cend () const noexcept |
| const_iterator | cend () noexcept |
Public Member Functions inherited from Aleph::FunctionalMixin< Derived, Type > | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &operation) const -> decltype(self()) |
| Apply an operation to each element (read-only). | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &operation) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &&operation=Operation()) const -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires CallableWith<Operation &, const Type &> | |
| auto | for_each (Operation &&operation=Operation()) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires CallableWith<Operation &, Type &> | |
| auto | mutable_for_each (Operation &operation) -> decltype(self()) |
| Apply an operation to each element (mutable). | |
| template<class Operation > requires CallableWith<Operation &, Type &> | |
| auto | mutable_for_each (Operation &&operation=Operation()) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | all (Operation &operation) const |
| Test if all elements satisfy a predicate. | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | all (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | forall (Operation &operation) const |
| Alias for all(). | |
| template<class Operation > requires requires(const typename concepts_detail::defer<Derived, Operation>::type &c, Operation &op) { { c.template traverse<Operation>(op) } -> std::convertible_to<bool>; } | |
| bool | forall (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| bool | exists (Operation &operation) const |
| Test if any element satisfies a predicate. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| bool | exists (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename __Type = Type, template< typename > class Container = Aleph::DynList, class Operation = Dft_Map_Op<Type, __Type>> requires requires(Container<__Type> &l, Operation &op, const Type &item) { l.append(op(item)); } | |
| Container< __Type > | maps (Operation &operation) const |
| Transform elements using a mapping function. | |
| template<typename __Type = Type, template< typename > class Container = Aleph::DynList, class Operation = Dft_Map_Op<Type, __Type>> requires requires(Container<__Type> &l, Operation &op, const Type &item) { l.append(op(item)); } | |
| Container< __Type > | maps (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<typename __Type = Type> | |
| __Type | foldl (const __Type &init, std::function< __Type(const __Type &, const Type &)> operation) const |
| Left fold (reduce) with initial value. | |
| template<typename __Type = Type> | |
| __Type | fold_left (std::function< __Type(const __Type &, const Type &)> operation, const __Type &init) const |
| Left fold with operation first (alternative signature). | |
| template<class Operation > requires requires(Type &acc, Operation &op, const Type &item) { acc = op(acc, item); } | |
| Type | fold (const Type &init, Operation &operation) const |
| Simple fold with same type for accumulator and elements. | |
| template<class Operation > requires requires(Type &acc, Operation &op, const Type &item) { acc = op(acc, item); } | |
| Type | fold (const Type &init, Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< Type > | filter (Operation &operation) const |
| Filter elements by a predicate. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< Type > | filter (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< std::tuple< Type, size_t > > | pfilter (Operation &operation) const |
| Filter with position information. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| DynList< std::tuple< Type, size_t > > | pfilter (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::pair< DynList< Type >, DynList< Type > > | partition (Operation &op) const |
| Partition elements by a predicate. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::pair< DynList< Type >, DynList< Type > > | partition (Operation &&op=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::tuple< DynList< Type >, DynList< Type > > | tpartition (Operation &op) const |
| Partition returning tuple instead of pair. | |
| template<class Operation > requires PredicateWith<Operation &, const Type &> | |
| std::tuple< DynList< Type >, DynList< Type > > | tpartition (Operation &&op=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| size_t | length () const noexcept |
| Count the number of elements. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | rev () const |
| Create a reversed copy. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | take (const size_t n) const |
| Take the first n elements. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | drop (const size_t n) const |
| Skip the first n elements. | |
| Type | sum (const Type &init=Type{}) const |
| Compute the sum of all elements. | |
| Type | product (const Type &init) const |
| Compute the product of all elements. | |
| const Type * | min () const |
| Find the minimum element. | |
| const Type * | max () const |
| Find the maximum element. | |
| template<class Compare > requires PredicateWith<Compare &, const Type &, const Type &> | |
| const Type * | min_by (Compare cmp) const |
| Find the minimum element using a custom comparator. | |
| template<class Compare > requires PredicateWith<Compare &, const Type &, const Type &> | |
| const Type * | max_by (Compare cmp) const |
| Find the maximum element using a custom comparator. | |
| bool | has_value (const Type &val) const |
| Check if container has a value. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| bool | none (Predicate &pred) const |
| Check if no element satisfies a predicate. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| bool | none (Predicate &&pred) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| size_t | count_if (Predicate pred) const |
| Count elements satisfying a predicate. | |
| const Type * | first () const |
| Get the first element. | |
| Type | first_or (const Type &default_val) const |
| Get the first element or a default value. | |
| const Type * | last () const |
| Get the last element. | |
| Type | last_or (const Type &default_val) const |
| Get the last element or a default value. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< std::pair< size_t, Type > > | enumerate () const |
| Enumerate elements with their indices. | |
| template<class Predicate > requires PredicateWith<Predicate &, const Type &> | |
| size_t | find_index (Predicate pred) const |
| Find the index of the first element satisfying a predicate. | |
| size_t | index_of (const Type &val) const |
| Find the index of a specific value. | |
| template<template< typename > class Container = Aleph::DynList> requires requires(Type a, Type b) { { a == b } -> std::convertible_to<bool>; } | |
| Container< Type > | unique () const |
| Remove consecutive duplicate elements. | |
| template<template< typename > class Container = Aleph::DynList, class EqPred > requires PredicateWith<EqPred &, const Type &, const Type &> | |
| Container< Type > | unique_by (EqPred eq) const |
| Remove consecutive duplicates using a custom equality predicate. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Type > | intersperse (const Type &sep) const |
| Intersperse a separator between elements. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Container< Type > > | chunk (size_t n) const |
| Split into chunks of fixed size. | |
| template<template< typename > class Container = Aleph::DynList> | |
| Container< Container< Type > > | sliding (size_t size, size_t step=1) const |
| Create sliding windows of fixed size. | |
| std::vector< Type > | to_vector () const |
| Convert to std::vector. | |
| template<typename DynListType = DynList<Type>> | |
| DynListType | to_dynlist () const |
| Convert container to DynList. | |
| template<typename StringType = std::string> requires requires(Type a) { std::to_string(a); } | |
| StringType | join (const StringType &sep=StringType{", "}) const |
| Join elements into a string with separator. | |
| std::string | join_str (const std::string &sep=", ") const |
| Join string elements with separator. | |
| template<class Other , template< typename > class Container = Aleph::DynList> | |
| Container< std::pair< Type, typename Other::Item_Type > > | zip_with (const Other &other) const |
| Zip with another container. | |
Static Public Member Functions | |
| static void | clone (const Tree_Node< char > *src, Tree_Node< char > *tgt) |
| Clone helper - copies children from src to tgt. | |
Private Member Functions | |
| void | words_impl (std::string &word, DynArray< std::string > &l, const size_t max_word_length) const |
Static Private Member Functions | |
| template<typename Node > | |
| static std::tuple< Node *, const char * > | search_prefix_impl (Node *root, const char *prefix) noexcept |
| Shared implementation for mutable and const prefix searches. | |
| template<typename Node > | |
| static Node * | search_child_impl (Node *root, const char c) noexcept |
| Shared implementation for mutable and const child lookup. | |
| template<typename Node > | |
| static Node * | greater_child_impl (Node *root, const char c) noexcept |
| Shared implementation for mutable and const sorted-child lookup. | |
Private Attributes | |
| bool | ends_word_ = false |
Additional Inherited Members | |
Public Types inherited from Aleph::Tree_Node< char > | |
| using | Item_Type = Tree_Node * |
| using | key_type = char |
| Generic data type stored in the node. | |
| using | iterator = __iterator< Tree_Node > |
| using | const_iterator = __const_iterator< Tree_Node > |
Protected Member Functions inherited from Aleph::FunctionalMixin< Derived, Type > | |
| const Derived & | self () const noexcept |
| Derived & | self () noexcept |
Low-level prefix tree node for storing character sequences.
Cnode implements a prefix tree (also known as a trie or digital tree) where each node represents a character. Words are stored as paths from the root. A node-local flag marks complete word endings, so every character value can be used as ordinary input data.
This is the legacy/manual node API. A Cnode does not own its descendants in its destructor; callers that build trees directly with Cnode must call destroy() before the root node is destroyed. Prefer Prefix_Tree when a normal owning container is desired.
Definition at line 126 of file prefix-tree.H.
Construct a node with the given character.
| [in] | c | Character to store in this node. |
Definition at line 328 of file prefix-tree.H.
References Aleph::Tree_Node< char >::get_key().
Return a list of all child nodes.
Definition at line 349 of file prefix-tree.H.
References Aleph::Tree_Node< char >::for_each_child(), and r.
|
inline |
Create a deep copy of this subtree.
| std::bad_alloc | If memory allocation fails. |
Definition at line 720 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), clone(), and symbol().
|
inlinestatic |
Clone helper - copies children from src to tgt.
| [in] | src | Source node to copy from. |
| [out] | tgt | Target node to copy to. |
| std::bad_alloc | If memory allocation fails. |
tgt: if cloning throws, any children appended by this call are removed and the previous word-ending flag is restored. Definition at line 690 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Tree_Node< char >::child, clone(), Aleph::Tree_Node< T >::get_left_child(), and Aleph::Tree_Node< T >::insert_rightmost_child().
Referenced by Aleph::Prefix_Tree::operator=(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
Check if a word exists in the tree.
| [in] | word | Word to search for. |
Definition at line 498 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), and search_word().
Referenced by Aleph::Prefix_Tree::contains().
|
inlinenoexcept |
Count total words stored in this subtree.
Definition at line 507 of file prefix-tree.H.
References count(), Aleph::Tree_Node< char >::for_each_child(), and is_end_word().
Referenced by count(), and Aleph::Prefix_Tree::count().
|
inlinenoexcept |
Destroy all children of this node.
Recursively deletes all descendant nodes. The node itself is not deleted.
Definition at line 617 of file prefix-tree.H.
References Aleph::destroy_tree(), Aleph::Tree_Node< char >::get_right_child(), and Aleph::Tree_Node< char >::set_is_leaf().
Referenced by Aleph::Cnode::Detached_Subtree_Guard::~Detached_Subtree_Guard(), Aleph::Prefix_Tree::destroy_root(), and PrefixTreeTest::TearDown().
Find the first const child with a character greater than c.
Used for inspecting the sorted child order.
| [in] | c | Character threshold. |
Definition at line 436 of file prefix-tree.H.
References greater_child_impl().
Find the first mutable child with a character greater than c.
Used for maintaining sorted order of children.
| [in] | c | Character threshold. |
Definition at line 424 of file prefix-tree.H.
References greater_child_impl().
Referenced by insert_child().
|
inlinestaticprivatenoexcept |
Shared implementation for mutable and const sorted-child lookup.
| [in] | root | Node whose children are searched. |
| [in] | c | Character threshold. |
root must not be nullptr. Definition at line 195 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Tree_Node< char >::child, and root().
Referenced by greater_child(), and greater_child().
Insert a child node in sorted order.
Children are maintained in ascending order by character.
| [in] | child | Node to insert. |
Definition at line 554 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Tree_Node< char >::child, greater_child(), Aleph::Tree_Node< char >::insert_rightmost_child(), search_child(), and Aleph::Tree_Node< char >::sibling.
Insert a word into the tree.
Creates all necessary nodes for the word and marks the ending.
| [in] | word | Word to insert. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 579 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Cnode::Pending_Path_Guard::release_nodes(), search_prefix(), and Aleph::Cnode::Pending_Path_Guard::set().
Referenced by Aleph::Prefix_Tree::insert_word(), and TEST().
|
inlinenoexcept |
Check if this node marks the end of a word.
A word ending is stored as node state instead of as a child sentinel.
Definition at line 380 of file prefix-tree.H.
References ends_word_.
Referenced by count(), mark_end_word(), TEST_F(), TEST_F(), and words_impl().
|
inline |
Mark this node as the end of a word.
Sets the node-local word-ending flag.
Definition at line 391 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), ends_word_, and is_end_word().
Referenced by TEST_F().
Print all words to stdout.
| [in] | max_word_length | Maximum expected word length (default 2048). |
Definition at line 670 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), FunctionalMethods< Container, T >::for_each(), w, and words().
Search for a const child with the given character.
| [in] | c | Character to search for. |
Definition at line 412 of file prefix-tree.H.
References search_child_impl().
Search for a mutable child with the given character.
| [in] | c | Character to search for. |
Definition at line 402 of file prefix-tree.H.
References search_child_impl().
Referenced by insert_child().
|
inlinestaticprivatenoexcept |
Shared implementation for mutable and const child lookup.
| [in] | root | Node whose children are searched. |
| [in] | c | Character to search for. |
root must not be nullptr. Definition at line 169 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Tree_Node< char >::child, and root().
Referenced by search_child(), and search_child().
|
inlinenoexcept |
Search for a prefix in the const tree.
Traverses the tree following the characters in prefix.
| [in] | prefix | Null-terminated string to search for. |
prefix must not be nullptr. Definition at line 466 of file prefix-tree.H.
References Aleph::prefix(), and search_prefix_impl().
|
inlinenoexcept |
Search for a prefix in the mutable tree.
Traverses the tree following the characters in prefix.
| [in] | prefix | Null-terminated string to search for. |
prefix must not be nullptr. Definition at line 451 of file prefix-tree.H.
References Aleph::prefix(), and search_prefix_impl().
Referenced by insert_word(), and words_with_prefix().
|
inlinestaticprivatenoexcept |
Shared implementation for mutable and const prefix searches.
| [in] | root | Node where the search starts. |
| [in] | prefix | Null-terminated prefix to search for. |
root and prefix must not be nullptr. Definition at line 141 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Tree_Node< char >::child, Aleph::prefix(), and root().
Referenced by search_prefix(), and search_prefix().
Search for a complete word in the tree.
| [in] | word | Null-terminated string to search for. |
word must not be nullptr. Definition at line 478 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching().
Referenced by contains().
|
inlinenoexcept |
Return the character stored in this node.
Definition at line 337 of file prefix-tree.H.
References Aleph::Tree_Node< char >::get_key().
Referenced by clone(), TEST(), TEST_F(), TEST_F(), and to_str().
|
inline |
Convert the subtree to a string representation.
Definition at line 363 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::Tree_Node< char >::for_each_child(), symbol(), and to_str().
Referenced by to_str().
|
inline |
Get all words stored in this subtree.
| [in] | max_word_length | Maximum expected word length (default 2048). |
max_word_length must be large enough for every stored word when assertions are enabled. Definition at line 655 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::DynArray< T >::reserve(), and words_impl().
Referenced by print_words(), and Aleph::Prefix_Tree::words().
|
inlineprivate |
Definition at line 629 of file prefix-tree.H.
References Aleph::DynList< T >::append(), Aleph::blossom_maximum_cardinality_matching(), Aleph::Tree_Node< char >::child, Aleph::Tree_Node< char >::get_left_child(), is_end_word(), l, and words_impl().
Referenced by words(), and words_impl().
|
inline |
Get all words starting with a given prefix.
| [in] | prefix | Prefix to search for. |
| [in] | max_word_length | Maximum expected word length (default 2048). |
max_word_length must be at least prefix.size() and large enough for every emitted word when assertions are enabled. Definition at line 527 of file prefix-tree.H.
References Aleph::blossom_maximum_cardinality_matching(), Aleph::prefix(), and search_prefix().
Referenced by Aleph::Prefix_Tree::words_with_prefix().
Definition at line 128 of file prefix-tree.H.
Referenced by Aleph::Cnode::Clone_Target_Rollback::Clone_Target_Rollback(), Aleph::Cnode::Clone_Target_Rollback::~Clone_Target_Rollback(), is_end_word(), and mark_end_word().