|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Tree_Node variant with a virtual destructor. More...
#include <tpl_tree_node.H>
Public Member Functions | |
| virtual | ~Tree_Node_Vtl ()=default |
Public Member Functions inherited from Aleph::Tree_Node< T > | |
| T & | get_key () noexcept |
| Returns a modifiable reference to the node contents. | |
| constexpr const T & | get_key () const noexcept |
| T & | get_data () noexcept |
| Returns a modifiable reference to the node contents. | |
| constexpr const T & | 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 T &d) | |
| Constructor with data value __data. | |
| Tree_Node (T &&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. | |
| template<template< typename > class Container = DynList> | |
| Container< Tree_Node * > | trees () const |
| Return a list with all trees belonging to the forest. | |
| template<typename Operation > | |
| void | for_each_child (Operation &op) const |
| Visits each child of this and executes the operation on the child node. | |
| template<typename Operation > | |
| void | for_each_child (Operation &&op=Operation()) const |
| template<template< typename > class Container = DynList> | |
| Container< Tree_Node * > | children_nodes () const |
| Returns a list with the child nodes of this. | |
| template<template< typename > class Container = DynList> | |
| Container< T > | children () const |
| Returns a list with the contents of the children of this. | |
| template<class Operation > | |
| bool | traverse (Operation op) |
| Preorder traversal over all nodes executing op. | |
| template<class Operation > | |
| bool | traverse (Operation op) const |
| template<class Op > | |
| bool | level_traverse (Op op) |
| template<class Op > | |
| bool | level_traverse (Op op) const |
| Children_Iterator | children_it () const |
| Iterator | get_it () const |
| iterator | begin () noexcept |
| iterator | end () noexcept |
| const_iterator | begin () const noexcept |
| const_iterator | end () const noexcept |
| const_iterator | cbegin () const noexcept |
| const_iterator | cend () const noexcept |
| const_iterator | cbegin () noexcept |
| const_iterator | cend () noexcept |
Public Member Functions inherited from Aleph::FunctionalMixin< Tree_Node< T >, Tree_Node< T > * > | |
| auto | for_each (Operation &operation) const -> decltype(self()) |
| Apply an operation to each element (read-only). | |
| 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. | |
| 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. | |
| 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. | |
| auto | mutable_for_each (Operation &operation) -> decltype(self()) |
| Apply an operation to each element (mutable). | |
| 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. | |
| bool | all (Operation &operation) const |
| Test if all elements satisfy a predicate. | |
| 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. | |
| bool | forall (Operation &operation) const |
| Alias for all(). | |
| 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. | |
| bool | exists (Operation &operation) const |
| Test if any element satisfies a predicate. | |
| 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. | |
| Container< __Type > | maps (Operation &operation) const |
| Transform elements using a mapping function. | |
| 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. | |
| __Type | foldl (const __Type &init, std::function< __Type(const __Type &, const Tree_Node< T > * &)> operation) const |
| Left fold (reduce) with initial value. | |
| __Type | fold_left (std::function< __Type(const __Type &, const Tree_Node< T > * &)> operation, const __Type &init) const |
| Left fold with operation first (alternative signature). | |
| Tree_Node< T > * | fold (const Tree_Node< T > * &init, Operation &operation) const |
| Simple fold with same type for accumulator and elements. | |
| Tree_Node< T > * | fold (const Tree_Node< T > * &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. | |
| DynList< Tree_Node< T > * > | filter (Operation &operation) const |
| Filter elements by a predicate. | |
| DynList< Tree_Node< T > * > | 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. | |
| DynList< std::tuple< Tree_Node< T > *, size_t > > | pfilter (Operation &operation) const |
| Filter with position information. | |
| DynList< std::tuple< Tree_Node< T > *, 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. | |
| std::pair< DynList< Tree_Node< T > * >, DynList< Tree_Node< T > * > > | partition (Operation &op) const |
| Partition elements by a predicate. | |
| std::pair< DynList< Tree_Node< T > * >, DynList< Tree_Node< T > * > > | 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. | |
| std::tuple< DynList< Tree_Node< T > * >, DynList< Tree_Node< T > * > > | tpartition (Operation &op) const |
| Partition returning tuple instead of pair. | |
| std::tuple< DynList< Tree_Node< T > * >, DynList< Tree_Node< T > * > > | 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. | |
| Container< Tree_Node< T > * > | rev () const |
| Create a reversed copy. | |
| Container< Tree_Node< T > * > | take (const size_t n) const |
| Take the first n elements. | |
| Container< Tree_Node< T > * > | drop (const size_t n) const |
| Skip the first n elements. | |
| Tree_Node< T > * | sum (const Tree_Node< T > * &init=Tree_Node< T > *{}) const |
| Compute the sum of all elements. | |
| Tree_Node< T > * | product (const Tree_Node< T > * &init) const |
| Compute the product of all elements. | |
| const Tree_Node< T > * * | min () const |
| Find the minimum element. | |
| const Tree_Node< T > * * | max () const |
| Find the maximum element. | |
| const Tree_Node< T > * * | min_by (Compare cmp) const |
| Find the minimum element using a custom comparator. | |
| const Tree_Node< T > * * | max_by (Compare cmp) const |
| Find the maximum element using a custom comparator. | |
| bool | has_value (const Tree_Node< T > * &val) const |
| Check if container has a value. | |
| bool | none (Predicate &pred) const |
| Check if no element satisfies a predicate. | |
| 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. | |
| size_t | count_if (Predicate pred) const |
| Count elements satisfying a predicate. | |
| const Tree_Node< T > * * | first () const |
| Get the first element. | |
| Tree_Node< T > * | first_or (const Tree_Node< T > * &default_val) const |
| Get the first element or a default value. | |
| const Tree_Node< T > * * | last () const |
| Get the last element. | |
| Tree_Node< T > * | last_or (const Tree_Node< T > * &default_val) const |
| Get the last element or a default value. | |
| Container< std::pair< size_t, Tree_Node< T > * > > | enumerate () const |
| Enumerate elements with their indices. | |
| size_t | find_index (Predicate pred) const |
| Find the index of the first element satisfying a predicate. | |
| size_t | index_of (const Tree_Node< T > * &val) const |
| Find the index of a specific value. | |
| Container< Tree_Node< T > * > | unique () const |
| Remove consecutive duplicate elements. | |
| Container< Tree_Node< T > * > | unique_by (EqPred eq) const |
| Remove consecutive duplicates using a custom equality predicate. | |
| Container< Tree_Node< T > * > | intersperse (const Tree_Node< T > * &sep) const |
| Intersperse a separator between elements. | |
| Container< Container< Tree_Node< T > * > > | chunk (size_t n) const |
| Split into chunks of fixed size. | |
| Container< Container< Tree_Node< T > * > > | sliding (size_t size, size_t step=1) const |
| Create sliding windows of fixed size. | |
| std::vector< Tree_Node< T > * > | to_vector () const |
| Convert to std::vector. | |
| DynListType | to_dynlist () const |
| Convert container to DynList. | |
| 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. | |
| Container< std::pair< Tree_Node< T > *, typename Other::Item_Type > > | zip_with (const Other &other) const |
| Zip with another container. | |
Additional Inherited Members | |
Public Types inherited from Aleph::Tree_Node< T > | |
| using | Item_Type = Tree_Node * |
| using | key_type = T |
| 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< Tree_Node< T >, Tree_Node< T > * > | |
| const Tree_Node< T > & | self () const noexcept |
| Tree_Node< T > & | self () noexcept |
Tree_Node variant with a virtual destructor.
Use this type when nodes are extended polymorphically and may be deleted through a pointer to the base tree-node type. Plain Tree_Node keeps the non-virtual destructor for minimal overhead.
| T | data type stored in each tree node. |
Definition at line 925 of file tpl_tree_node.H.
|
virtualdefault |