|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Files | |
| file | avlNode.H |
| AVL tree node with balance factor. | |
| file | avlNodeRk.H |
| AVL tree node with rank (subtree count). | |
| file | btreepic_avl.H |
| AVL tree visualization utilities. | |
| file | generate_tree.H |
| Tree visualization and output generation. | |
| file | opBinTree.H |
| Optimal Binary Search Tree construction using dynamic programming. | |
| file | prefix-tree.H |
| Trie (prefix tree) implementation. | |
| file | random_tree.H |
| Random tree generation using GSL random number generator. | |
| file | rbNode.H |
| Red-Black tree node definition and validation utilities. | |
| file | rbNodeRk.H |
| Red-Black tree node with rank (subtree count). | |
| file | tpl_arrayHeap.H |
| Fixed-capacity binary heap and heapsort algorithms. | |
| file | tpl_avl.H |
| AVL tree implementation (height-balanced BST). | |
| file | tpl_avlRk.H |
| AVL tree with rank (order statistics). | |
| file | tpl_balanceXt.H |
| Tree balancing with extended nodes. | |
| file | tpl_binHeap.H |
| Binary heap implementation using tree structure. | |
| file | tpl_binNode.H |
| Basic binary tree node definitions. | |
| file | tpl_binNodeAux.H |
| Binary tree node base definitions and declaration macros. | |
| file | tpl_binNodeUtils.H |
| Utility functions for binary tree operations. | |
| file | tpl_binNodeXt.H |
| Extended binary node with subtree count. | |
| file | tpl_binTree.H |
| Generic unbalanced binary search tree. | |
| file | tpl_binTreeOps.H |
| Binary tree operations (split, join, rotate). | |
| file | tpl_dynArrayHeap.H |
| Array-based dynamic binary heap. | |
| file | tpl_dynBinHeap.H |
| Dynamic binary heap with node-based storage. | |
| file | tpl_dynMapTree.H |
| Dynamic key-value map based on balanced binary search trees. | |
| file | tpl_dynSetTree.H |
| Dynamic set implementations based on balanced binary search trees. | |
| file | tpl_dynSkipList.H |
| Dynamic ordered set implemented with a Skip List. | |
| file | tpl_dynTreap.H |
| Dynamic treap alias. | |
| file | tpl_nodePool.H |
| Tree node memory pool allocator. | |
| file | tpl_rand_tree.H |
| Randomized binary search tree. | |
| file | tpl_randNode.H |
| Randomized tree node. | |
| file | tpl_rb_tree.H |
| Red-Black tree implementation (bottom-up balancing). | |
| file | tpl_rbNode.H |
| Red-Black node type alias. | |
| file | tpl_rbRk.H |
| Red-Black tree with rank (order statistics). | |
| file | tpl_skipList.H |
| Skip list: probabilistic sorted linked structure. | |
| file | tpl_splay_tree.H |
| Top-down splay tree implementation (without rank support). | |
| file | tpl_splay_treeRk.H |
| Top-down splay tree with rank support. | |
| file | tpl_tdRbTree.H |
| Top-down Red-Black tree implementation. | |
| file | tpl_tdRbTreeRk.H |
| Top-down Red-Black tree with rank support. | |
| file | tpl_treap.H |
| Treap: randomized BST combining tree and heap properties. | |
| file | tpl_treapRk.H |
| Treap with rank (order statistics). | |
| file | tpl_tree_node.H |
| General tree (n-ary tree) node. | |
| file | tpl_union.H |
| Union-Find (Disjoint Set Union) data structure. | |
| file | treapNode.H |
| Treap node definition with BST key and heap priority. | |
Classes | |
| class | AvlNode_Data |
| Data portion of an AVL tree node. More... | |
| class | Aleph::Huffman_Encoder_Engine |
| Huffman encoder. More... | |
| struct | Aleph::Huffman_Encoder_Engine::Get_Key |
| struct | Aleph::Huffman_Encoder_Engine::Load_Key |
| class | Aleph::Huffman_Decoder_Engine |
| Huffman decoder. More... | |
| class | Aleph::Cnode |
| Prefix tree (Trie) node for storing character sequences. More... | |
| class | RandTree< T > |
| Generator for uniformly random trees. More... | |
| class | RbNode_Data |
| Data portion of a Red-Black tree node. More... | |
| class | Aleph::ArrayHeap< T, Compare > |
| Fixed-capacity binary heap backed by a raw array. More... | |
| struct | Aleph::ArrayHeap< T, Compare >::Iterator |
| class | Aleph::Gen_Avl_Tree< NodeType, Key, Compare > |
| AVL balanced binary search tree. More... | |
| struct | Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::Iterator |
| Iterator over the nodes. More... | |
| struct | Aleph::Avl_Tree< Key, Compare > |
| AVL binary search tree with nodes without virtual destructor. More... | |
| struct | Aleph::Avl_Tree_Vtl< Key, Compare > |
| AVL binary search tree with virtual destructor in its nodes. More... | |
| class | Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare > |
| AVL balanced binary search tree with rank (order statistics). More... | |
| class | Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::Iterator |
| Iterator over the nodes. More... | |
| struct | Aleph::Avl_Tree_Rk< Key, Compare > |
| AVL binary search tree with nodes without virtual destructor and with subtree counters for select/position operations. More... | |
| struct | Aleph::Avl_Tree_Rk_Vtl< Key, Compare > |
| AVL binary search tree with virtual destructor in its nodes and with subtree counters for select/position operations. More... | |
| class | Aleph::GenBinHeap< NodeType, Key, Compare > |
| Heap genérico de nodos. More... | |
| class | Aleph::GenBinHeap< NodeType, Key, Compare >::Iterator |
| struct | Aleph::BinHeap< Key, Compare > |
| Node heap without virtual destructor. More... | |
| struct | Aleph::BinHeapVtl< Key, Compare > |
| Heap of nodes with virtual destroyer. More... | |
| class | Aleph::For_Each_In_Order< Node > |
| Generic inorder traversal of a binary tree. More... | |
| class | Aleph::For_Each_Preorder< Node > |
| Generic preorder traversal of a binary tree. More... | |
| class | Aleph::For_Each_Postorder< Node > |
| Generic postorder traversal of a binary tree. More... | |
| class | Aleph::BinNodePrefixIterator< Node > |
| Preorder iterator on the nodes of a binary tree. More... | |
| class | Aleph::BinNodeInfixIterator< Node > |
| Inorder iterator on the nodes of a binary tree. More... | |
| class | Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare > |
| Base iterator template for ranked binary search trees. More... | |
| class | Aleph::GenBinTree< NodeType, Key, Compare > |
| Simple (unbalanced) binary search tree. More... | |
| struct | Aleph::GenBinTree< NodeType, Key, Compare >::Iterator |
| Iterator on nodes of the tree. More... | |
| struct | Aleph::BinTree< Key, Compare > |
| Binary search tree with nodes without virtual destructors,. More... | |
| struct | Aleph::BinTreeVtl< Key, Compare > |
| Binary search tree with nodes with virtual destructors,. More... | |
| class | Aleph::BinTree_Operation< Node, Cmp > |
| Functor encompassing basic operation for binary search trees. More... | |
| class | Aleph::BinTreeXt_Operation< Node, Cmp > |
| Functor encompassing basic operation for extended binary search trees. More... | |
| class | Aleph::DynArrayHeap< T, Compare > |
Dynamic heap (priority queue) backed by DynArray. More... | |
| struct | Aleph::DynArrayHeap< T, Compare >::Iterator |
| class | Aleph::DynBinHeap< T, Compare > |
Dynamic heap of elements of type T ordered by a comparison functor. More... | |
| struct | Aleph::DynBinHeap< T, Compare >::Iterator |
| class | Aleph::DynMapTree< Key, Data, Tree, Compare > |
| Generic key-value map implemented on top of a binary search tree. More... | |
| class | Aleph::DynMapBinTree< Key, Type, Compare > |
| Dynamic map implemented with a classic binary search tree. More... | |
| class | Aleph::DynMapAvlTree< Key, Type, Compare > |
| Dynamic map implemented with an AVL tree. More... | |
| class | Aleph::DynMapRbTree< Key, Type, Compare > |
| Dynamic map implemented with a red-black tree. More... | |
| class | Aleph::DynMapRandTree< Key, Type, Compare > |
| Dynamic map implemented with a randomized BST. More... | |
| class | Aleph::DynMapTreap< Key, Type, Compare > |
| Dynamic map implemented with a treap. More... | |
| class | Aleph::DynMapTreapRk< Key, Type, Compare > |
| Dynamic map implemented with a ranked treap. More... | |
| class | Aleph::DynMapSplayTree< Key, Type, Compare > |
| Dynamic map implemented with a splay tree. More... | |
| class | Aleph::DynSetTree< Key, Tree, Compare > |
| Dynamic set backed by balanced binary search trees with automatic memory management. More... | |
| struct | Aleph::DynSetTree< Key, Tree, Compare >::Has_Range_Methods< T > |
| struct | Aleph::DynSetTree< Key, Tree, Compare >::Node_Op< Key_Op > |
| struct | Aleph::DynSetTree< Key, Tree, Compare >::Iterator |
| class | Aleph::DynSetBinTree< Key, Compare > |
| Dynamic set implemented using binary search trees of type BinTree<Key>. More... | |
| class | Aleph::DynSetAvlTree< Key, Compare > |
| Dynamic set implemented using AVL binary search trees of type Avl_Tree<Key>. More... | |
| class | Aleph::DynSetSplayTree< Key, Compare > |
| Dynamic set implemented using splay binary search trees of type Splay_Tree<Key>. More... | |
| class | Aleph::DynSetSplayRkTree< Key, Compare > |
| Dynamic set implemented using splay trees with rank support of type Splay_Tree_Rk<Key>. More... | |
| class | Aleph::DynSetSplayRkTree< Key, Compare >::Iterator |
| class | Aleph::DynSetRandTree< Key, Compare > |
| Dynamic set implemented using randomized binary search trees of type Rand_Tree<Key>. More... | |
| class | Aleph::DynSetRandTree< Key, Compare >::Iterator |
| class | Aleph::DynSetTreap< Key, Compare > |
| Dynamic set implemented using randomized treap binary search trees of type Treap<Key>. More... | |
| class | Aleph::DynSetTreapRk< Key, Compare > |
| Dynamic set implemented using extended treap binary search trees with rank support of type Treap_Rk<Key>. More... | |
| class | Aleph::DynSetTreapRk< Key, Compare >::Iterator |
| class | Aleph::DynSetAvlRkTree< Key, Compare > |
| Dynamic set implemented using extended AVL binary search trees with rank support of type Avl_Tree_Rk<Key>. More... | |
| class | Aleph::DynSetAvlRkTree< Key, Compare >::Iterator |
| class | Aleph::DynSetRbTree< Key, Compare > |
| Dynamic set implemented using Red-Black binary search trees of type Rb_Tree<Key> (bottom-up implementation). More... | |
| class | Aleph::DynSetTdRbTree< Key, Compare > |
| Dynamic set implemented using Top-Down Red-Black binary search trees of type TdRbTree<Key>. More... | |
| class | Aleph::DynSetRbRkTree< Key, Compare > |
| Dynamic set implemented using extended Red-Black binary search trees with rank support of type Rb_Tree_Rk<Key> (bottom-up implementation). More... | |
| class | Aleph::DynSetRbRkTree< Key, Compare >::Iterator |
| class | Aleph::DynSetTdRbRkTree< Key, Compare > |
| Dynamic set implemented using Top-Down Red-Black binary search trees with rank support of type TdRbTreeRk<Key>. More... | |
| class | Aleph::DynSetTdRbRkTree< Key, Compare >::Iterator |
| class | Aleph::DynSetHtdRbTree< Key, Compare > |
| Dynamic set implemented using Hybrid Top-Down/Bottom-Up Red-Black trees of type HtdRbTree<Key>. More... | |
| class | Aleph::DynSetHtdRbTree< Key, Compare >::Iterator |
| class | Aleph::DynSetHtdRbRkTree< Key, Compare > |
| Dynamic set implemented using Hybrid Red-Black trees with rank support of type HtdRbTreeRk<Key>. More... | |
| class | Aleph::DynSetHtdRbRkTree< Key, Compare >::Iterator |
| class | Aleph::HtdRbTree< Key, Compare > |
| Hybrid top-down/bottom-up red-black tree. More... | |
| struct | Aleph::HtdRbTree< Key, Compare >::Iterator |
| In-order iterator. More... | |
| class | Aleph::HtdRbTreeRk< Key, Compare > |
| Hybrid top-down/bottom-up red-black tree with rank support. More... | |
| struct | Aleph::HtdRbTreeRk< Key, Compare >::Iterator |
| In-order iterator. More... | |
| class | Aleph::Gen_Rand_Tree< NodeType, Key, Compare > |
| Randomized binary search tree with rank support. More... | |
| struct | Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::Iterator |
| Iterator on nodes of the tree. More... | |
| struct | Aleph::Rand_Tree< Key, Compare > |
| Randomized binary search tree. More... | |
| struct | Aleph::Rand_Tree_Vtl< Key, Compare > |
| Randomized binary search tree. More... | |
| class | Aleph::Gen_Rb_Tree< NodeType, Key, Compare > |
| Red-black binary search tree implementation (bottom-up). More... | |
| struct | Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::Iterator |
| Iterator over tree nodes in sorted order. More... | |
| struct | Aleph::Rb_Tree< Key, Compare > |
| Red-black tree with nodes without virtual destructor. More... | |
| struct | Aleph::Rb_Tree_Vtl< Key, Compare > |
| Red-black tree with virtual destructor in nodes. More... | |
| class | Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare > |
| Red-black tree with rank support (select/position operations). More... | |
| class | Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::Iterator |
| Iterator on nodes of the tree. More... | |
| struct | Aleph::Rb_Tree_Rk< Key, Compare > |
| Red-Black binary search tree with nodes without virtual destructor and with subtree counters for select/position operations. More... | |
| struct | Aleph::Rb_Tree_Rk_Vtl< Key, Compare > |
| Red-Black binary search tree with virtual destructor in its nodes and with subtree counters for select/position operations. More... | |
| class | GenTdSplayTree< NodeType, Key, Compare > |
| Top-down splay tree - Self-adjusting BST with amortized O(log n) operations. More... | |
| struct | GenTdSplayTree< NodeType, Key, Compare >::Iterator |
| Iterator over the nodes. More... | |
| class | GenTdSplayTreeRk< NodeType, Key, Compare > |
| Top-down splay tree with rank support. More... | |
| class | GenTdSplayTreeRk< NodeType, Key, Compare >::Iterator |
| Inorder iterator over the extended splay tree. More... | |
| class | Aleph::GenTdRbTree< NodeType, Key, Compare > |
| Top-down red-black binary search tree implementation. More... | |
| struct | Aleph::GenTdRbTree< NodeType, Key, Compare >::Iterator |
| Iterator over tree nodes in sorted order. More... | |
| class | Aleph::GenTdRbTreeRk< NodeType, Key, Compare > |
| Top-down red-black tree with rank support (select/position). More... | |
| struct | Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::Iterator |
| Iterator. More... | |
| class | Aleph::Gen_Treap< NodeType, Key, Compare > |
| Treap - A randomized binary search tree using heap-ordered priorities. More... | |
| struct | Aleph::Gen_Treap< NodeType, Key, Compare >::Iterator |
| Iterator on nodes of the tree. More... | |
| struct | Aleph::Treap< Key, Compare > |
| Treap (a special type of randomized binary search tree) using nodes without virtual destructor. More... | |
| struct | Aleph::Treap_Vtl< Key, Compare > |
| Treap (a special type of randomized binary search tree) using nodes with virtual destructors. More... | |
| class | Aleph::Gen_Treap_Rk< NodeType, Key, Compare > |
| Extended Treap with rank support for O(log n) indexed access. More... | |
| class | Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator |
| Iterator on nodes of the tree. More... | |
| struct | Aleph::Treap_Rk< Key, Compare > |
| Extended treap (a special type of randomized binary search tree) which manages selection and splitting for inorder position. More... | |
| struct | Aleph::Treap_Rk_Vtl< Key, Compare > |
| Extended treap (a special type of randomized binary search tree) which manages selection and splitting for inorder position. More... | |
| class | Aleph::Tree_Node< T > |
| Generic m-ary trees. More... | |
| class | Aleph::TreapNode_Data |
| Data portion of a treap node. More... | |
| class | Aleph::BinNode< Key > |
| Node for binary search tree. More... | |
| class | Aleph::BinNodeXt< Key > |
| Node for extended binary search tree. More... | |
Macros | |
| #define | DECLARE_BINNODE(Name, height, Control_Data) |
| Specify tree node for a binary tree. | |
| #define | DECLARE_BINNODE_SENTINEL(Name, height, Control_Data) |
| Specify tree node for a binary tree. | |
Functions | |
| template<typename Node , class Write = Dft_Write<Node>> | |
| void | Aleph::generate_tree (Node *root, std::ostream &out, const int &tree_number=0) |
| Generate a tree specification for the ntreepic drawing tool. | |
| template<typename Node , class Write = Dft_Write<Node>> | |
| void | Aleph::generate_forest (Node *root, std::ostream &out) |
| Generate a forest specification for the ntreepic drawing tool. | |
| template<typename Node , class Write > | |
| void | Aleph::generate_btree (Node *root, std::ostream &out) |
| Generate a binary tree specification for the btreepic drawing tool. | |
| template<class Node , typename Key > | |
| Node * | Aleph::build_optimal_tree (Key keys[], double p[], const size_t n) |
| Build an optimal binary search tree based on access probabilities. | |
| template<class Node > | |
| Node * | Aleph::select_gotoup_root (Node *root, const size_t &i) |
| Selecciona un nodo de un Ă¡rbol binario segĂºn su posiciĂ³n infija y lo convierte en su raĂz. | |
| template<class Node > | |
| constexpr Node *& | Aleph::LLINK (Node *p) noexcept |
| Return a pointer to left subtree. | |
| template<class Node > | |
| constexpr Node *& | Aleph::RLINK (Node *p) noexcept |
| Return the right tree of p. | |
| template<class Node > | |
| constexpr Node::Key_Type & | Aleph::KEY (Node *p) noexcept |
| Return a modifiable reference to the key stored in the node. | |
| template<class Node > | |
| int | Aleph::inOrderRec (Node *root, void(*visitFct)(Node *, int, int)) |
| Traverse recursively inorder a binary tree. | |
| template<class Node > | |
| int | Aleph::preOrderRec (Node *root, void(*visitFct)(Node *, int, int)) |
| Traverse recursively in preorder a binary tree. | |
| template<class Node > | |
| int | Aleph::postOrderRec (Node *root, void(*visitFct)(Node *, int, int)) |
| Traverse recursively in postorder a binary tree. | |
| template<class Node , class Op > | |
| void | Aleph::for_each_in_order (Node *root, Op &&op) |
| Execute an operation in order sense for each node of tree. | |
| template<class Node , class Op > | |
| void | Aleph::for_each_preorder (Node *root, Op &&op) |
| Execute an operation in preorder sense for each node of tree. | |
| template<class Node , class Op > | |
| void | Aleph::for_each_postorder (Node *root, Op &&op) |
| Execute an operation in postorder sense for each node of tree. | |
| template<class Node > | |
| DynList< Node * > | Aleph::prefix (Node *root) |
| Return a list with preorder traversal of a tree. | |
| template<class Node > | |
| DynList< Node * > | Aleph::infix (Node *root) |
| Return a list with inorder traversal of a tree. | |
| template<class Node > | |
| DynList< Node * > | Aleph::suffix (Node *root) |
| Return a list with postorder traversal of a tree. | |
| template<class Node > | |
| size_t | Aleph::compute_cardinality_rec (Node *root) noexcept |
| Count the number of nodes of a binary tree. | |
| template<class Node > | |
| size_t | Aleph::computeHeightRec (Node *root) noexcept |
Compute recursively the height of root | |
| template<class Node > | |
| void | Aleph::destroyRec (Node *&root) noexcept |
Free recursively all the memory occupied by the tree root | |
| template<class Node > | |
| Node * | Aleph::copyRec (Node *root) |
| Copy recursively a tree. | |
| template<class Node > | |
| void | Aleph::levelOrder (Node *root, void(*visitFct)(Node *, int, bool)) |
| Traverse a binary tree by levels. | |
| template<class Node , class Operation > | |
| bool | Aleph::level_traverse (Node *root, Operation &operation) |
| Level traverse a tree and execute an operation. | |
| template<template< class > class Node, typename Key > | |
| Node< Key > * | Aleph::build_tree (const DynArray< Key > &preorder, long l_p, long r_p, const DynArray< Key > &inorder, long l_i, long r_i) |
| Build a binary tree form its preorder and inorder traversals. | |
| template<class Node > | |
| DynDlist< Node * > | Aleph::compute_nodes_in_level (Node *root, const int &level) |
| Count the number of nodes in a specific tree level. | |
| template<class Node > | |
| void | Aleph::inOrderThreaded (Node *root, void(*visitFct)(Node *)) |
| Traverse inorder a binary tree without recursion and without stack. | |
| template<class Node > | |
| void | Aleph::preOrderThreaded (Node *node, void(*visitFct)(Node *)) |
| Traverse preorder a binary tree without recursion and without stack. | |
| template<class Node > | |
| size_t | Aleph::internal_path_length (Node *p) noexcept |
| Compute the internal path length. | |
| template<class Node > | |
| void | Aleph::tree_to_bits (Node *root, BitArray &array) |
| Compute a bit code for the binary tree. | |
| template<class Node > | |
| BitArray | Aleph::tree_to_bits (Node *root) |
| Compute a bit code for the binary tree. | |
| template<class Node > | |
| Node * | Aleph::bits_to_tree (const BitArray &array, int idx=0) |
| Build a binary tree given its bits code. | |
| template<class Node > | |
| void | Aleph::save_tree_keys_in_prefix (Node *root, std::ostream &output) |
| Store in output stream the tree keys in preorder. | |
| template<class Node > | |
| void | Aleph::load_tree_keys_in_prefix (Node *root, std::istream &input) |
| Load the keys stored in preorder from an input stream. | |
| template<class Node > | |
| void | Aleph::save_tree (Node *root, std::ostream &output) |
| Store a binary tree in a stream. | |
| template<class Node > | |
| Node * | Aleph::load_tree (std::istream &input) |
| Load and build a binary tree from a stream. | |
| template<class Node , class Get_Key > | |
| void | Aleph::save_tree_in_array_of_chars (Node *root, const std::string &array_name, std::ostream &output) |
| Generate C++ array declarations for a binary tree. | |
| template<class Node , class Load_Key > | |
| Node * | Aleph::load_tree_from_array (const unsigned char bits[], const size_t &num_bits, const char *keys[]) |
| Build a binary tree from two arrays. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| bool | Aleph::check_bst (Node *p, const Compare &cmp=Compare()) |
Return true if p is a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::preorder_to_bst (DynArray< typename Node::key_type > &preorder, int l, int r, const Compare &cmp=Compare()) |
| Build a binary search tree from its preorder traversal. | |
| template<typename T , class Compare = Aleph::less<T>> | |
| ThreeWayCmp | Aleph::three_way_compare (const T &a, const T &b, const Compare &cmp=Compare()) noexcept |
| Three-way comparison using a binary comparator. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::searchInBinTree (Node *root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept |
| Search a key in a binary search tree. | |
| template<class Node > | |
| Node * | Aleph::find_min (Node *root) noexcept |
| Return the minimum key contained in a binary search tree. | |
| template<class Node > | |
| Node * | Aleph::find_max (Node *root) noexcept |
| Return the maximum key contained in a binary search tree. | |
| template<class Node > | |
| Node * | Aleph::find_successor (Node *p, Node *&pp) noexcept |
Find the inorder successor of p | |
| template<class Node > | |
| Node * | Aleph::find_predecessor (Node *p, Node *&pp) noexcept |
Find the inorder predecessor of p | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::search_parent (Node *root, const typename Node::key_type &key, Node *&parent, const Compare &cmp=Compare()) noexcept |
| Search a key and find its node and parent. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::search_rank_parent (Node *root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept |
| Rank search of a key in a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::insert_in_bst (Node *&r, Node *p, const Compare &cmp=Compare()) noexcept |
Insert a node p in a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::insert_dup_in_bst (Node *&root, Node *p, const Compare &cmp=Compare()) noexcept |
Insert a node p in a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::search_or_insert_in_bst (Node *&r, Node *p, const Compare &cmp=Compare()) noexcept |
| Search or insert a node in a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| bool | Aleph::split_key_rec (Node *&root, const typename Node::key_type &key, Node *&ts, Node *&tg, const Compare &cmp=Compare()) noexcept |
| Split recursively according to a key. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| void | Aleph::split_key_dup_rec (Node *&root, const typename Node::key_type &key, Node *&ts, Node *&tg, const Compare &cmp=Compare()) noexcept |
| Split a tree according to a key value. | |
| template<class Node > | |
| Node * | Aleph::join_exclusive (Node *&ts, Node *&tg) noexcept |
| Exclusive join of two binary trees. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::remove_from_bst (Node *&root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept |
| Remove a key from a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::insert_root (Node *&root, Node *p, const Compare &cmp=Compare()) noexcept |
Insert the node p as root of a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::insert_dup_root (Node *&root, Node *p, const Compare &cmp=Compare()) noexcept |
Insert node p as root of a binary search tree. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::join_preorder (Node *t1, Node *t2, Node *&dup, const Compare &cmp=Compare()) noexcept |
| Union of two binary search trees. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::join (Node *t1, Node *t2, Node *&dup, const Compare &cmp=Compare()) noexcept |
| Fast union of two binary search trees. | |
| template<class Node > | |
| Node * | Aleph::rotate_to_right (Node *p) noexcept |
Rotate to the right the tree with root p | |
| template<class Node > | |
| Node * | Aleph::rotate_to_right (Node *p, Node *pp) noexcept |
Rotate to the right the tree with root p and update its parent. | |
| template<class Node > | |
| Node * | Aleph::rotate_to_left (Node *p) noexcept |
Rotate to the left the tree with root p | |
| template<class Node > | |
| Node * | Aleph::rotate_to_left (Node *p, Node *pp) noexcept |
Rotate to the left the tree with root p and update its parent. | |
| template<class Node , class Key , class Compare = Aleph::less<typename Node::key_type>> | |
| void | Aleph::split_key (Node *&root, const Key &key, Node *&l, Node *&r, const Compare &cmp=Compare()) noexcept |
| Split a binary search tree according to a key. | |
| template<class Node > | |
| void | Aleph::swap_node_with_successor (Node *p, Node *&pp, Node *q, Node *&pq) noexcept |
| Swap a node with its successor inorder. | |
| template<class Node > | |
| void | Aleph::swap_node_with_predecessor (Node *p, Node *&pp, Node *q, Node *&pq) noexcept |
| Swap a node with its predecessor inorder. | |
| template<class Node , class Key = typename Node::key_type, class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::insert_root_rec (Node *root, Node *p, const Compare &cmp=Compare()) noexcept |
| Insert a node as root in a binary search tree. | |
| template<class Node , class Key = typename Node::key_type, class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::search_or_insert_root_rec (Node *root, Node *p, const Compare &cmp=Compare()) noexcept |
Search and eventually insert p as root in a binary search tree. | |
| template<class Node , class Op > | |
| bool | Aleph::prefix_traverse (Node *root, Op op) |
| Traverse a tree in preorder via its iterator and performs a conditioned operation on each item. | |
| template<class Node , class Op > | |
| bool | Aleph::infix_traverse (Node *root, Op op) |
| Traverse a tree in inorder via its iterator and performs a conditioned operation on each item. | |
| template<class Node > | |
| auto & | Aleph::COUNT (Node *p) noexcept |
Return the number of nodes of the tree fron p is root. | |
| template<class Node > | |
| Node * | Aleph::select_rec (Node *r, const size_t i) |
| Recursively select the i-th node inorder sense. | |
| template<class Node > | |
| Node * | Aleph::select_ne (Node *r, const size_t pos) noexcept |
| Iterative selection of a node according to inorder position without exception. | |
| template<class Node > | |
| Node * | Aleph::select (Node *r, const size_t pos) |
| Iterative selection of a node according to inorder position. | |
| template<class Node , class Compare > | |
| long | Aleph::inorder_position (Node *r, const typename Node::key_type &key, Node *&p, Compare &cmp) noexcept |
| Compute the inorder position of a key. | |
| template<class Node , class Compare > | |
| Node * | Aleph::insert_by_key_xt (Node *&r, Node *p, Compare &cmp) noexcept |
| Insert a node in an extended binary search tree. | |
| template<class Node , class Compare > | |
| Node * | Aleph::insert_dup_by_key_xt (Node *&r, Node *p, Compare &cmp) noexcept |
| Insert a node in an extended binary search tree without testing for duplicity. | |
| template<class Node , class Compare > | |
| bool | Aleph::split_key_rec_xt (Node *&root, const typename Node::key_type &key, Node *&l, Node *&r, Compare &cmp) noexcept |
| Split an extended binary search tree according to a key. | |
| template<class Node , class Compare > | |
| void | Aleph::split_key_dup_rec_xt (Node *&root, const typename Node::key_type &key, Node *&l, Node *&r, Compare &cmp) noexcept |
| Split an extended binary search tree according to a key which can be in the tree. | |
| template<class Node , class Compare > | |
| Node * | Aleph::insert_root_xt (Node *&root, Node *p, Compare &cmp) noexcept |
Insert a node p as root of an extended binary search tree. | |
| template<class Node , class Compare > | |
| Node * | Aleph::insert_dup_root_xt (Node *&root, Node *p, Compare &cmp) noexcept |
| Insert a node as root of an extended binary search tree. | |
| template<class Node > | |
| void | Aleph::split_pos_rec (Node *&r, const size_t i, Node *&ts, Node *&tg) |
| Split a extended binary tree according to a position. | |
| template<class Node > | |
| void | Aleph::insert_by_pos_xt (Node *&r, Node *p, size_t pos) |
| Insert a node in a specific inorder position in a binary tree. | |
| template<class Node > | |
| Node * | Aleph::join_exclusive_xt (Node *&ts, Node *&tg) noexcept |
| Exclusive union of two extended binary search trees. | |
| template<class Node , class Compare = Aleph::less<typename Node::key_type>> | |
| Node * | Aleph::remove_by_key_xt (Node *&root, const typename Node::key_type &key, Compare &cmp) noexcept |
| Remove a key of extended binary tree. | |
| template<class Node > | |
| Node * | Aleph::remove_by_pos_xt (Node *&root, size_t pos) |
Remove from a extended binary tree the node whose inorder position is pos. | |
| template<class Node > | |
| bool | Aleph::check_rank_tree (Node *root) noexcept |
Return true if root is a valid extended binary tree. | |
| template<class Node > | |
| Node * | Aleph::rotate_to_right_xt (Node *p) noexcept |
Rotate to right the extended bianry tree with root p | |
| template<class Node > | |
| Node * | Aleph::rotate_to_left_xt (Node *p) noexcept |
Rotate to left the extended binary tree with root p. | |
| Node * | Aleph::BinTree_Operation< Node, Cmp >::search_rank_parent (Node *root, const Key &key) noexcept |
| Rank search of a key in a binary search tree. | |
| long | Aleph::BinTreeXt_Operation< Node, Cmp >::inorder_position (Node *r, const Key &key, Node *&p) noexcept |
| Compute the inorder position of a key. | |
| Node * | Aleph::BinTreeXt_Operation< Node, Cmp >::insert_root (Node *&root, Node *p) noexcept |
Insert a node p as root of an extended binary search tree. | |
| DynSetTree & | Aleph::DynSetTree< Key, Tree, Compare >::join (DynSetTree &t, DynSetTree &dup) |
| Union of two binary search trees. | |
| DynSetTree & | Aleph::DynSetTree< Key, Tree, Compare >::join_dup (DynSetTree &t) |
| Union of two binary search trees. | |
| std::pair< long, Node * > | Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::position (const Key &key) const noexcept |
| Compute the inorder position of a key. | |
| std::pair< int, Node * > | Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::position (const Key &key) const noexcept |
| Compute the inorder position of a key. | |
| template<class Node > | |
| void | Aleph::tree_preorder_traversal (Node *root, void(*visitFct)(Node *, int, int)) |
| Preorder traversal of a tree. | |
| template<class Node > | |
| void | Aleph::forest_preorder_traversal (Node *root, void(*visitFct)(Node *, int, int)) |
| Preorder traversal of a forest. | |
| template<class Node > | |
| void | Aleph::tree_postorder_traversal (Node *root, void(*visitFct)(Node *, int, int)) |
| Postorder traversal of a tree. | |
| template<class Node > | |
| void | Aleph::forest_postorder_traversal (Node *root, void(*visitFct)(Node *, int, int)) |
| Postorder traversal of a forest. | |
| template<class Node , class Eq > | |
| bool | Aleph::are_tree_equal (Node *t1, Node *t2, Eq &eq) |
| Returns true if t1 is equal to t2. | |
| template<class Node > | |
| void | Aleph::destroy_tree (Node *root) |
| Destroys (frees memory) the tree whose root is root. | |
| template<class Node > | |
| void | Aleph::destroy_forest (Node *root) |
| Destroys (frees memory) the forest whose first tree is root. | |
| template<class Node > | |
| size_t | Aleph::compute_height (Node *root) |
| Computes the height of the tree root. | |
| template<class Node > | |
| Node * | Aleph::deway_search (Node *root, int path[], const size_t &size) |
| Returns a node of a forest given its Dewey number. | |
| template<class Node , class Equal = Aleph::equal_to<typename Node::key_type>> | |
| Node * | Aleph::search_deway (Node *root, const typename Node::key_type &key, int deway[], const size_t &size, size_t &n) |
| Searches key in a forest and computes the Dewey number of the node containing the key. | |
| template<class TNode , class BNode > | |
| BNode * | Aleph::forest_to_bin (TNode *root) |
| Converts a forest to its equivalent binary tree. | |
| template<class TNode , class BNode > | |
| TNode * | Aleph::bin_to_forest (BNode *broot) |
| Converts a binary tree to its equivalent forest. | |
| template<class Node > | |
| unsigned long & | Aleph::PRIO (Node *p) noexcept |
| Access the priority of a treap node. | |
In Aleph-w ( \(\aleph_\omega\)) the binary trees are managed by nodes, not by the keys that these contain. Many tree operations, concretely those modifying them, take as parameters nodes. For example, ig you have a binary search tree of integers, and you want to insert 10, then you must first allocate the node, put it the key and then insert into the tree. Some such as:
Bintree<int>::Node * p = new Bintree<int>::Node(10); tree.insert(p);
This usage is some complicated and tedious most of the time. However, it simplifies enormously the tree algorithms, since these do not need to worry by memory management. Eventually, it could also simplificate the user's life and definitively improve the performance. Suppose for example that you have two trees, and you need to remove a key from one and insert it into the another. In this case you could do as follows:
auto ptr = tree.remove(10); // remove node with 10 and return ptr tree2.insert(ptr);
If the tree managed the memory, then the removal from tree1 would perform a delete. Afterward, in order to insert 10 into tree2 it would be need to allocate the node, copy it the 10 and insert it into the tree. As you see
If this sound some complicated, do not worry. Aleph-w ( \(\aleph_\omega\)) exports other interfaces that wrappers and automatize the memory management.
Another advantage of Aleph-w ( \(\aleph_\omega\)) approach for binary trees is that it allows to extend the data contained in the nodes by inheritance. Suppose that you search by a integer value, but that you have several types of data. Consider for example Student and Professor classes, then you could do:
Professor_Node : public BinTree<int>::Node { ... }; Student_Node : public BinTree<int>::Node { ... };
Since that tree operations are by BinTree<int>::Node, you could then insert student and professors nodes, and eventually other derived types, without need of change your insertion code. Of course, specific code related to a specific class will need to cast from BinTree<int>::Node to the correspondent derived class for some operations.
If you use the technique explained above and the derived class is enough complex, then perhaps you need to call to the destructor of derived class when you perform delete on a node pointer. In this case, you need that the destructor of BinTree<int>::Node is virtual. In this situation you must use BinTreeVtl<int> in order to indicate that the node destructor is virtual.
The same approach is used for the remainder of binary trees: Avl, Splay, ...
This separation is desirable because if you know that do not need to call to the derived destructor, then you can save memory by using nodes with simple destructors.
| #define DECLARE_BINNODE | ( | Name, | |
| height, | |||
| Control_Data | |||
| ) |
Specify tree node for a binary tree.
DECLARE_BINNODE(Name, height, Control_Data) generates two classes of binary nodes called Name and NameVtl, respectevely. The only difference is expressed by the fact that for NameVtl its destructor is virtual.
Each node has an attribute called key, accessible through KEY(p) or p->get_key(), where p is a pointer to the node.
A binary node has two static attributes:
NullPtr which represents to the empty treeMaxHeight: an estimated value of maximum height of tree. This value is used as helper for recursive and stack based algorithms for allocate enough stack space.| Name | the name of class defining the node. |
| height | maximum height that could have the tree |
| Control_Data | control data according to tree type |
Definition at line 255 of file tpl_binNode.H.
| #define DECLARE_BINNODE_SENTINEL | ( | Name, | |
| height, | |||
| Control_Data | |||
| ) |
Specify tree node for a binary tree.
DECLARE_BINNODE_SENTINEL(Name, height, Control_Data) generates two classes of binary nodes called Name and NameVtl, respectively. The only difference is expressed by the fact that for NameVtl its destructor is virtual.
In this version, a special static member called sentinel_node is declared. In this context, a sentinel node is a node representing the empty tree whose state is initialized by the call to Control_Data(sentinelCtor).
Each node has an attribute called key, accessible through KEY(p) or p->get_key(), where p is a pointer to the node.
A binary node has two static attributes:
NullPtr which represents to the empty treeMaxHeight: an estimated value of maximun height of tree. This value is used as helper for recursive and stack based algorithms for allocate enough stack space.| Name | the name of class defining the node. |
| height | maximun height that could have the tree |
| Control_Data | control data according to tree type |
Definition at line 295 of file tpl_binNode.H.
Returns true if t1 is equal to t2.
Definition at line 962 of file tpl_tree_node.H.
References Aleph::all(), Aleph::are_tree_equal(), Aleph::eq(), Aleph::maps(), and Aleph::zipEq().
Referenced by Aleph::are_tree_equal(), and TEST().
Converts a binary tree to its equivalent forest.
bin_to_forest(root) takes a binary tree derived from BinNode and converts it to its equivalent forest.
The routine takes two type parameters:
The procedure assumes that both types share the same key type.
| [in] | broot | root of the binary tree to convert. |
| bad_alloc | if there is not enough memory. |
Definition at line 1286 of file tpl_tree_node.H.
References Aleph::bin_to_tree(), KEY, and Aleph::maps().
Build a binary tree given its bits code.
bits_to_tree(array, idx) takes a bit array and from the starting index idx builds the corresponding tree.
| [in] | array | bits array |
| [in] | idx | starting index |
| bad_alloc | if there is no enough memory |
Definition at line 1126 of file tpl_binNodeUtils.H.
References Aleph::maps().
Referenced by TEST().
Build an optimal binary search tree based on access probabilities.
Constructs a binary search tree that minimizes the expected search cost given the access probabilities for each key. Uses dynamic programming with Knuth's optimization for O(n²) time and O(n²) space complexity.
The algorithm computes the optimal root for each subproblem [i,j] using the monotonicity property: root[i,j-1] ≤ root[i,j] ≤ root[i+1,j]
| Node | Binary tree node type. Must provide:
|
| Key | Key type stored in the tree nodes. |
| [in] | keys | Array of n keys in sorted order (0-indexed). |
| [in] | p | Array of n access probabilities (0-indexed), parallel to keys. Should sum to 1.0 for proper interpretation as probabilities. |
| [in] | n | Number of keys. |
| std::bad_alloc | If memory allocation fails. |
Definition at line 191 of file opBinTree.H.
References Aleph::compute_optimal_costs(), and Aleph::maps().
|
inline |
Build a binary tree form its preorder and inorder traversals.
build_tree() takes two dynamic arrays with the preorder and inorder traversal of keys and builds the correspondent tree.
| [in] | preorder | array with the preorder traversal |
| [in] | l_p | first index in preorder |
| [in] | r_p | last index in preorder |
| [in] | inorder | array with the preorder traversal |
| [in] | l_i | first index in inorder |
| [in] | r_i | last index in inorder |
| bad_alloc | if there is no enough memory |
Definition at line 763 of file tpl_binNodeUtils.H.
References ah_domain_error_if, inorder(), Aleph::LLINK(), Aleph::maps(), preorder(), Aleph::RLINK(), and root().
Return true if p is a binary search tree.
| [in] | p | root of the tree |
| [in] | cmp | comparison criteria |
true if p is a binary search tree according to Compare criteria. Definition at line 1402 of file tpl_binNodeUtils.H.
References cmp(), and Aleph::maps().
Referenced by Aleph::is_red_black_bst_rk(), main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::DynSetTree< Key, Tree, Compare >::verify(), GenTdSplayTree< NodeType, Key, Compare >::verify(), and GenTdSplayTreeRk< NodeType, Key, Compare >::verify().
Return true if root is a valid extended binary tree.
Definition at line 907 of file tpl_binNodeXt.H.
References Aleph::check_rank_tree(), Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by Aleph::check_rank_tree(), main(), TEST(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::verify(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::verify(), GenTdSplayTreeRk< NodeType, Key, Compare >::verify(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::verify(), and Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::verify().
Count the number of nodes of a binary tree.
| [in] | root | of tree |
Definition at line 479 of file tpl_binNodeUtils.H.
References Aleph::compute_cardinality_rec(), Aleph::LLINK(), Aleph::RLINK(), and root().
Referenced by Aleph::compute_cardinality_rec(), Aleph::DynSetTree< Key, Tree, Compare >::join(), Aleph::DynSetTree< Key, Tree, Compare >::join_dup(), Aleph::size(), Aleph::DynSetTree< Key, Tree, Compare >::split_key(), Aleph::DynSetTree< Key, Tree, Compare >::split_key_dup(), and Aleph::DynSetTree< Key, Tree, Compare >::split_pos().
Computes the height of the tree root.
| [in] | root | tree root. |
Definition at line 1062 of file tpl_tree_node.H.
References Aleph::compute_height(), Aleph::maps(), and root().
Referenced by Aleph::compute_height().
Count the number of nodes in a specific tree level.
| [in] | root | of tre |
| [in] | level | desired to be counted |
level | bad_alloc | if there is no enough memory |
Definition at line 860 of file tpl_binNodeUtils.H.
References Aleph::compute_nodes_in_level_helper(), and root().
Referenced by south_offset(), and TEST().
Compute recursively the height of root
| [in] | root | of tree |
Definition at line 503 of file tpl_binNodeUtils.H.
References Aleph::computeHeightRec(), Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by benchmark_set(), compute_picture_size(), Aleph::computeHeightRec(), demonstrate_tree_types(), Aleph::DynSetTree< Key, Tree, Compare >::height(), is_avl(), Aleph::is_avl_rk(), main(), sample_tree(), set_picture_size(), write_avl(), write_bin(), write_rand(), write_rb(), write_splay(), and write_treap().
Copy recursively a tree.
| [in] | root | of tre to be copied |
root | bad_alloc | if there is no enough memory |
Definition at line 571 of file tpl_binNodeUtils.H.
References Aleph::destroyRec(), Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by Aleph::DynSetTree< Key, Tree, Compare >::DynSetTree(), and Aleph::DynSetTree< Key, Tree, Compare >::operator=().
Return the number of nodes of the tree fron p is root.
| p | pointer to root |
Definition at line 81 of file tpl_binNodeXt.H.
Referenced by GenTdSplayTreeRk< NodeType, Key, Compare >::__insert(), Aleph::__remove_by_pos_xt(), Aleph::__select_rec(), Aleph::__split_key_dup_rec_xt(), Aleph::__split_key_rec_xt(), Aleph::__split_pos_rec(), Aleph::balance_tree(), Aleph::check_rank_tree(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateRight(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::extract_max_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::extract_min_rb(), GenTdSplayTreeRk< NodeType, Key, Compare >::find_position(), Aleph::BinTreeXt_Operation< Node, Cmp >::find_position(), Aleph::find_position(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::find_succ_and_swap(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::findPredAndSwap(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::findSuccAndSwap(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::get_current_position(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::get_current_position(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::has_curr(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::has_curr(), Aleph::HtdRbTreeRk< Key, Compare >::init(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::init(), Aleph::BinTreeXt_Operation< Node, Cmp >::inorder_position(), Aleph::inorder_position(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert(), GenTdSplayTreeRk< NodeType, Key, Compare >::insert(), Aleph::HtdRbTreeRk< Key, Compare >::insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::insert(), Aleph::insert_by_key_xt(), Aleph::insert_by_pos_xt(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::HtdRbTreeRk< Key, Compare >::insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::insert_dup(), Aleph::insert_dup_by_key_xt(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_dup_root(), Aleph::insert_dup_root_xt(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_root(), Aleph::insert_root_xt(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::is_container_empty(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::is_container_empty(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::join_exclusive_xt(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_left_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_right_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_with_pivot_rb(), GenTdSplayTreeRk< NodeType, Key, Compare >::position(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), GenTdSplayTreeRk< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove(), Aleph::remove_by_key_xt(), Aleph::remove_by_pos_xt(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove_pos(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove_pos(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::reset_last(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::reset_last(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_left_simple(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_right_simple(), Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_left_rk(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_to_left_rk(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::rotate_to_left_rk(), Aleph::rotate_to_left_xt(), Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_right_rk(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_to_right_rk(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::rotate_to_right_rk(), Aleph::rotate_to_right_xt(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateRight(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::HtdRbTreeRk< Key, Compare >::search_or_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::search_or_insert(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::search_or_insert(), Aleph::search_or_insert_by_key_xt(), Aleph::search_or_insert_root_rec_xt(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::select(), Aleph::select(), Aleph::select_gotoup_root(), Aleph::select_ne(), Aleph::select_rec(), GenTdSplayTreeRk< NodeType, Key, Compare >::size(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::size(), Aleph::HtdRbTreeRk< Key, Compare >::size(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::size(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::size(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::size(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::size(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_impl(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec(), Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_dup_rec(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec(), Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_rec(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_rec_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::split_pos_rec(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos_rec(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos_rec_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::swapWithSuccessor(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::update_counters_after_deletion(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::update_counters_after_deletion(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::update_counters_after_insertion(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::update_counters_after_insertion(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_curr(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr(), Aleph::HtdRbTreeRk< Key, Compare >::updateCountRec(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::updateCountRec(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::updateCountsFromStack(), and Aleph::HtdRbTreeRk< Key, Compare >::verifyCountsRec().
Destroys (frees memory) the forest whose first tree is root.
destroy_forest(root) frees all the memory occupied by the forest whose first tree has root as its root.
| [in] | root | root of the first tree of the forest to be destroyed. |
| domain_error | if root is not the root node of the leftmost tree of the forest. |
Definition at line 1037 of file tpl_tree_node.H.
References ah_domain_error_if, Aleph::destroy_tree(), Aleph::maps(), root(), and SIBLING_LIST.
Destroys (frees memory) the tree whose root is root.
destroy_tree(root) frees all the memory occupied by the tree whose root is root.
| [in] | root | root of the tree to be freed. |
Definition at line 1003 of file tpl_tree_node.H.
References CHILD_LIST, Aleph::destroy_tree(), IS_UNIQUE_SIBLING, Aleph::maps(), root(), and SIBLING_LIST.
Referenced by Simple_Tree::~Simple_Tree(), Three_Trees::~Three_Trees(), Aleph::Cnode::destroy(), Aleph::destroy_forest(), Aleph::destroy_tree(), main(), read_input_and_build_tree(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
Free recursively all the memory occupied by the tree root
new operator.| [in] | root | of tree to free |
Definition at line 524 of file tpl_binNodeUtils.H.
References Aleph::destroyRec(), Aleph::LLINK(), Aleph::RLINK(), and root().
Referenced by Aleph::bits_to_tree_helper(), Aleph::copyRec(), Aleph::destroyRec(), Aleph::DynSetTree< Key, Tree, Compare >::empty(), Aleph::Huffman_Encoder_Engine::load_tree(), Aleph::load_tree(), main(), main(), RandTree< T >::operator()(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::operator=(), test(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), write_avl(), write_bin(), write_rand(), write_rb(), write_splay(), and write_treap().
Returns a node of a forest given its Dewey number.
deway_search(root,path,size) takes the Dewey number stored in path, of length size, and searches in the forest whose first tree is root for the node that corresponds to the given Dewey number.
| [in] | root | root of the first tree of the forest. |
| [in] | path | array containing the Dewey number. |
| [in] | size | length of the Dewey number. |
Definition at line 1110 of file tpl_tree_node.H.
References Aleph::__deway_search(), root(), and Aleph::size().
Referenced by parse_deway_number().
Return the maximum key contained in a binary search tree.
| [in] | root | of tree |
Definition at line 1548 of file tpl_binNodeUtils.H.
References Aleph::maps(), Aleph::RLINK(), and root().
Referenced by east_offset(), Aleph::DynSetTree< Key, Tree, Compare >::max(), and TEST().
Return the minimum key contained in a binary search tree.
| [in] | root | of tree |
Definition at line 1529 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and root().
Referenced by Aleph::DynSetTree< Key, Tree, Compare >::min(), TEST(), and west_offset().
Find the inorder predecessor of p
| [in] | p | a node pointer |
| [out] | pp | p's parent |
p Definition at line 1593 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by TEST().
Find the inorder successor of p
| [in] | p | a node pointer |
| [out] | pp | p's parent |
p Definition at line 1567 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by TEST().
Execute an operation in order sense for each node of tree.
| [in] | root | of tree |
| [in] | op | operation to be executed on each node |
Definition at line 256 of file tpl_binNodeUtils.H.
References Aleph::maps(), root(), and GenericTraverse< Container >::traverse().
Execute an operation in postorder sense for each node of tree.
| [in] | root | of tree |
| [in] | op | operation to be executed on each node |
Definition at line 386 of file tpl_binNodeUtils.H.
References Aleph::maps(), root(), and GenericTraverse< Container >::traverse().
Execute an operation in preorder sense for each node of tree.
| [in] | root | of tree |
| [in] | op | operation to be executed on each node |
Definition at line 321 of file tpl_binNodeUtils.H.
References Aleph::maps(), root(), and GenericTraverse< Container >::traverse().
Postorder traversal of a forest.
forest_postorder_traversal((root,visit) performs a postorder traversal over the forest whose first tree is root. If visitFct is specified, then for each visited node the function is invoked.
The visit function has the following specification:
void (visitFct)(Node p, int level, int pos)
Where:
| [in] | root | root of the tree to traverse. |
| [in] | visitFct | pointer to the visit function. |
| domain_error | if root is not the root node of the leftmost tree of the forest. |
Definition at line 944 of file tpl_tree_node.H.
References Aleph::__tree_postorder_traversal(), ah_domain_error_if, Aleph::maps(), and root().
Referenced by main().
Preorder traversal of a forest.
forest_preorder_traversal((root,visit) performs a preorder traversal over the forest whose first tree is root. If visitFct is specified, then for each visited node the function is invoked.
The visit function has the following specification:
void (visitFct)(Node p, int level, int pos)
Where:
| [in] | root | root of the first tree in the forest. |
| [in] | visitFct | pointer to the visit function. |
| domain_error | if root is not a root node of a tree. |
Definition at line 867 of file tpl_tree_node.H.
References Aleph::__tree_preorder_traversal(), ah_domain_error_if, Aleph::maps(), and root().
Referenced by main().
Converts a forest to its equivalent binary tree.
forest_to_bin(root) takes a forest derived from Tree_Node and converts it to its equivalent binary tree.
The routine takes two type parameters:
The procedure assumes that both types share the same key type.
| [in] | root | root of the first tree belonging to the forest to convert. |
| bad_alloc | if there is not enough memory. |
Definition at line 1219 of file tpl_tree_node.H.
References Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Generate a binary tree specification for the btreepic drawing tool.
Produces a text specification for drawing binary trees using the btreepic program. The output contains both prefix and infix traversal sequences.
Output format:
| Node | Binary tree node type |
| Write | Functor that writes node content to output stream. Invoked as: Write()(node) during traversals |
| root | Root of the binary tree to draw |
| out | Output stream for the drawing specification |
Definition at line 207 of file generate_tree.H.
References Aleph::maps(), and root().
Generate a forest specification for the ntreepic drawing tool.
Produces a text specification for drawing a forest (collection of trees linked as siblings). Each tree is numbered starting from 0.
The forest is represented as siblings of the first root node:
| Node | Tree node type (must be Tree_Node or compatible) |
| Write | Functor that converts node key to string for display. Must provide: std::string operator()(Node*) |
| root | Root of the first tree in the forest |
| out | Output stream for the drawing specification |
Definition at line 174 of file generate_tree.H.
References Aleph::maps(), and root().
Referenced by TEST().
Generate a tree specification for the ntreepic drawing tool.
Produces a text specification that can be used with the ntreepic program to generate visual representations of tree structures.
The output format uses Dewey decimal notation to identify nodes:
| Node | Tree node type (must be Tree_Node or compatible) |
| Write | Functor that converts node key to string for display. Must provide: std::string operator()(Node*) |
| root | Root of the tree to draw |
| out | Output stream for the drawing specification |
| tree_number | Internal use - tree index in a forest (default: 0) |
Definition at line 128 of file generate_tree.H.
References deway(), Aleph::maps(), Aleph::Max_Tree_Node_Depth, root(), and tree_number.
Referenced by TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
Return a list with inorder traversal of a tree.
| [in] | root | of tree |
| bad_alloc | if there is no enough memory |
Definition at line 448 of file tpl_binNodeUtils.H.
References Aleph::infix(), Aleph::maps(), and root().
Traverse a tree in inorder via its iterator and performs a conditioned operation on each item.
infix_traverse(root, operation) instantiates the internal iterator of the class and traverses each item performing operation(p), where p is a node pointer.
operation must have the following signature:
bool operation(Node * p)
If operation(p) returns true then the iterator is advanced and the next item processed. Otherwise. the traversal stops.
| root | ||
| [in] | op | operation to be performed on each item |
true if all the nodes were visited (operation on each one always returned true) or false if the traversal was stopped because there was a false result on an item. | anything | that could throw operation |
Definition at line 2866 of file tpl_binNodeUtils.H.
References Aleph::BinNodeInfixIterator< Node >::has_curr(), Aleph::maps(), and root().
Referenced by Aleph::traverse().
|
inlinenoexcept |
Compute the inorder position of a key.
| [in] | r | root of tree |
| [in] | key | to be searched |
| [out] | p | pointer to the node containing key |
key if this is in the tree or -1 if key is not found Definition at line 616 of file tpl_binTreeOps.H.
References Aleph::BinTree_Operation< Node, Cmp >::cmp, Aleph::COUNT(), Aleph::BinTreeXt_Operation< Node, Cmp >::inorder_position(), KEY, Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
|
inlinenoexcept |
Compute the inorder position of a key.
| [in] | r | root of tree |
| [in] | key | to be searched |
| [out] | p | pointer to the node containing key |
| [in] | cmp | comparison criteria |
key Definition at line 219 of file tpl_binNodeXt.H.
References cmp(), Aleph::COUNT(), Aleph::inorder_position(), KEY, Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::inorder_position(), Aleph::inorder_position(), Aleph::inorder_position(), Aleph::inorder_position(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::position(), Aleph::HtdRbTreeRk< Key, Compare >::position(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::position(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::position(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::position(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::position(), TEST(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_pos(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_pos().
Traverse recursively inorder a binary tree.
inOrderRec(root,visit) performs an inorder traversal of tree rooted by root and on each node executes a visit function with the following signature:
void (*visitFct)(Node* p, int level, int pos)
Where:
p: pointer to visited node.level: level of node p.pos: ordinal indicating the visited order
For_Each_In_Order or traverse() instead| [in] | root | pointer to tree's root |
| [in] | visitFct | pointer to visit function |
Definition at line 97 of file tpl_binNodeUtils.H.
References Aleph::inorder_rec_helper(), Aleph::maps(), and root().
Referenced by build_tree(), huffman_to_btreepic(), main(), and write_rb().
Traverse inorder a binary tree without recursion and without stack.
inOrderThreaded(root,visit) traverses inorder the binary tree by building partial threads to succesor nodes. This implicates that during the traversal the links coulld be invalid.
The visit function has the following signature:
void (*visitFct)(Node* p, int level, int pos)
Where:
p: pointer to the currently visited nodelevel: the level of visited node| [in] | root | of tree |
| [in] | visitFct | pointer to visit function |
Definition at line 889 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by TEST().
Insert a node in an extended binary search tree.
insert_by_key_xt(root, p, cmp) inserts the nodepin the extended binary search tree with rootr`.
| [in,out] | r | the tree root |
| [in] | p | the node to insert |
| [in] | cmp | comparison criteria |
p->get_key() is not in the tree, then p is returned (is was inserted). Otherwise it returns Node::NullPtr Definition at line 353 of file tpl_binNodeXt.H.
References cmp(), Aleph::COUNT(), Aleph::insert_by_key_xt(), KEY, Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::insert_by_key_xt(), Aleph::insert_by_key_xt(), main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
Insert a node in a specific inorder position in a binary tree.
insert_by_pos_xt(r, p, pos) inserts in the position pos the node p.
p, the insertion could violate the required order for a binary search tree| [in,out] | r | root of tree |
| [in] | p | node to insert |
| [in] | pos | position to insert the node |
Definition at line 756 of file tpl_binNodeXt.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and Aleph::split_pos_rec().
Referenced by TEST().
Insert a node in an extended binary search tree without testing for duplicity.
| [in,out] | r | the tree root |
| [in] | p | pointer to the node to be inserted |
| [in] | cmp | comparison criteria |
Definition at line 398 of file tpl_binNodeXt.H.
References cmp(), Aleph::COUNT(), Aleph::insert_dup_by_key_xt(), KEY, Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::insert_dup_by_key_xt(), Aleph::insert_dup_by_key_xt(), TEST(), and TEST().
|
inlinenoexcept |
Insert a node p in a binary search tree.
insert_dup_in_bst(root, p) inserts the node p in the binary search tree with root. The key contained in p can be already present in the tree.
| [in,out] | root | of tree |
| [in] | p | pointer to the node to be inserted |
| [in] | cmp | comparison criteria |
p Definition at line 1746 of file tpl_binNodeUtils.H.
References cmp(), Aleph::insert_dup_in_bst(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by Aleph::insert_dup_in_bst(), and TEST().
|
inlinenoexcept |
Insert node p as root of a binary search tree.
The key of p can be duplicated.
| [in,out] | root | of tree |
| [in] | p | node to insert as root |
| [in] | cmp | comparison criteria |
p which has became the root of tree Definition at line 2018 of file tpl_binNodeUtils.H.
References cmp(), KEY, Aleph::LLINK(), Aleph::RLINK(), root(), and Aleph::split_key_dup_rec().
Referenced by TEST().
Insert a node as root of an extended binary search tree.
insert_dup_root_xt(root, p, cmp) inserts the node p as the new root of the tree root.
This insertion allows duplicates.
| [in,out] | root | of tree |
| [in] | p | pointer to the to insert |
| [in] | cmp | comparison criteria |
p that has became root Definition at line 657 of file tpl_binNodeXt.H.
References cmp(), Aleph::COUNT(), KEY, Aleph::LLINK(), Aleph::RLINK(), root(), and Aleph::split_key_dup_rec_xt().
Referenced by Aleph::insert_dup_root_xt(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), and TEST().
Insert a node p in a binary search tree.
insert_in_bst(root, p) inserts the node p in the binary search tree with root
| [in,out] | r | of tree. |
| [in] | p | pointer to the node to be inserted. |
| [in] | cmp | comparison criteria. |
p if this was inserted; that is if p->get_key() is not in the tree; otherwise, Node::NullPtr is returned Definition at line 1715 of file tpl_binNodeUtils.H.
References cmp(), KEY, Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::join(), Aleph::join_preorder(), main(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Insert a node p as root of an extended binary search tree.
insert_root_xt(root, p) inserts as root in the extended binary search tree root the node p. After insertion, if there is no duplicated key, p becomes the root of the tree.
| [in,out] | root | of tree |
| [in] | p | pointer to the node to insert |
p is not in tree, then returns p, since this was inserted and has became the root. Otherwise, it returns Node::NullPtr Definition at line 798 of file tpl_binTreeOps.H.
References Aleph::COUNT(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), root(), and Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_rec().
Referenced by Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert().
|
inlinenoexcept |
Insert the node p as root of a binary search tree.
insert_root(root, p, cmp) inserts in the tree root the node p. After insertion, p becomes the new root of tree.
| [in,out] | root | of binary search tree |
| [in] | p | pointer to node to insert |
| [in] | cmp | comparison criteria |
p if this was inserted; that is, if p->get_key() was not present in the tree. Otherwise, no insertion is done and Node::NullPtr is returned Definition at line 1991 of file tpl_binNodeUtils.H.
References cmp(), KEY, l, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), root(), and Aleph::split_key_rec().
Referenced by Aleph::join(), main(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), and TEST().
|
inlinenoexcept |
Insert a node as root in a binary search tree.
This version first inserts p as a leaf of a tree. Then p is rotated until the root.
| [in] | root | of tree |
| [in] | p | pointer to the node to insert |
| [in] | cmp | comparison criteria |
p if p->get_key() is not in the tree. Otherwise the function returns Node::NullPtr Definition at line 2391 of file tpl_binNodeUtils.H.
References cmp(), Aleph::insert_root_rec(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), root(), Aleph::rotate_to_left(), and Aleph::rotate_to_right().
Referenced by Aleph::insert_root_rec(), TEST(), and TEST().
Insert a node p as root of an extended binary search tree.
insert_root_xt(root, p) inserts as root in the extended binary search tree root the node p. After insertion, if there is no duplicated key, p becomes the root of the tree.
| [in,out] | root | of tree |
| [in] | p | pointer to the node to insert |
| [in] | cmp | comparison criteria |
p is not in tree, then returns p, since this was inserted and has become the root. Otherwise, it returns Node::NullPtr Definition at line 616 of file tpl_binNodeXt.H.
References cmp(), Aleph::COUNT(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), root(), and Aleph::split_key_rec_xt().
Referenced by Aleph::insert_root_xt(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), and TEST().
Compute the internal path length.
| [in] | p | root of tree |
Definition at line 1003 of file tpl_binNodeUtils.H.
References Aleph::internal_path_length_helper().
Referenced by benchmark_set(), Aleph::DynSetTree< Key, Tree, Compare >::internal_path_length(), sample_tree(), and TEST().
|
inline |
Union of two binary search trees.
join(t,dup) builds a binary search tree corresponding to the union of this with t. Duplicate keys are inserted in dup.
| [in] | t | binary search tree to join with this. |
| [out] | dup | binary search tree with duplicate keys from t. |
Definition at line 1319 of file tpl_dynSetTree.H.
References Aleph::compute_cardinality_rec(), Aleph::DynSetTree< Key, Tree, Compare >::join(), Aleph::DynSetTree< Key, Tree, Compare >::num_nodes, and Aleph::DynSetTree< Key, Tree, Compare >::tree.
Referenced by Aleph::DynSetTree< Key, Tree, Compare >::join(), and Aleph::DynSetTree< Key, Tree, Compare >::join().
|
inlinenoexcept |
Fast union of two binary search trees.
join(t1, t2, dup, cmp) joins the nodes of t1 with the nodes of t2. The duplicated keys of t2 are copied in the binary search tree dup.
| [in] | t1 | root of first tree |
| [in] | t2 | root of second tree |
| [out] | dup | tree where the duplicated keys of t2 are put |
| [in] | cmp | comparison criteria |
Definition at line 2078 of file tpl_binNodeUtils.H.
References cmp(), Aleph::insert_in_bst(), Aleph::insert_root(), Aleph::join(), KEY, l, Aleph::LLINK(), Aleph::maps(), Aleph::remove_from_bst(), Aleph::HTList::reset(), and Aleph::RLINK().
|
inline |
Union of two binary search trees.
join_dup(t) builds a binary search tree corresponding to the union of this with t in which there may be duplicate keys.
| [in] | t | binary search tree that you want to join to this. |
Definition at line 1355 of file tpl_dynSetTree.H.
References Aleph::compute_cardinality_rec(), Aleph::DynSetTree< Key, Tree, Compare >::join_dup(), Aleph::DynSetTree< Key, Tree, Compare >::num_nodes, and Aleph::DynSetTree< Key, Tree, Compare >::tree.
Referenced by Aleph::DynSetTree< Key, Tree, Compare >::join_dup().
Exclusive join of two binary trees.
join_exclusive(ts, tg) joins ts and ts. The exclusive sense means that all the keys of ts are lesser that all the keys of tg
| [in] | ts | tree with keys lesser than tg |
| [in] | tg | tree with keys greater than ts |
Definition at line 1924 of file tpl_binNodeUtils.H.
References Aleph::join_exclusive(), Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::join_exclusive(), Aleph::BinTree_Operation< Node, Cmp >::remove(), and Aleph::remove_from_bst().
Exclusive union of two extended binary search trees.
join_exclusive_xt(ts, tg) joins ts with tg in a tree. The trees must be exclusive in the sense that the all the keys of ts must be lesser than all the keys of tg.
| [in] | ts | extended binary search tree with keys lesser than tg |
| [in] | tg | extended binary search tree with keys greater than tg |
Definition at line 778 of file tpl_binNodeXt.H.
References Aleph::COUNT(), Aleph::join_exclusive_xt(), Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::__remove_by_pos_xt(), Aleph::join_exclusive_xt(), Aleph::remove_by_key_xt(), and TEST().
|
inlinenoexcept |
Union of two binary search trees.
t1 and t2respectively. Use join() which is much more faster| [in] | t1 | root of first tree |
| [in] | t2 | root of second tree |
| [out] | dup | root of tree where the duplicated keys will be put |
| [in] | cmp | comparison criteria |
Definition at line 2041 of file tpl_binNodeUtils.H.
References cmp(), Aleph::insert_in_bst(), Aleph::join_preorder(), l, Aleph::LLINK(), Aleph::maps(), Aleph::HTList::reset(), and Aleph::RLINK().
Referenced by Aleph::join_preorder(), and TEST().
Return a modifiable reference to the key stored in the node.
Definition at line 355 of file tpl_binNode.H.
Level traverse a tree and execute an operation.
operation() must have the following signature:
bool operation(Node* p)
if the result is true then the traversal continues; otherwise it stops.
| [in] | root | of tree |
| [in] | operation | to execute on each visited node |
true if all the nodes were visited; false otherwise Definition at line 717 of file tpl_binNodeUtils.H.
References Aleph::DynListQueue< T >::get(), Aleph::DynListQueue< T >::is_empty(), Aleph::LLINK(), Aleph::maps(), Aleph::DynListQueue< T >::put(), Aleph::RLINK(), and root().
Traverse a binary tree by levels.
The visit function must have the following signature:
void (*visitFct)(Node* p, int level, bool is_left)
Where:
p: pointer to currently visited nodepos: ordinal indicating the visit orderis_left: true if p is a left child; false otherwise| [in] | root | of tree |
| [in] | visitFct | visit function |
| bad_alloc | if there is no enough memory |
Definition at line 676 of file tpl_binNodeUtils.H.
References Aleph::DynListQueue< T >::get(), Aleph::DynListQueue< T >::is_empty(), Aleph::LLINK(), Aleph::maps(), Aleph::DynListQueue< T >::put(), Aleph::RLINK(), and root().
Referenced by huffman_to_btreepic().
Return a pointer to left subtree.
Definition at line 322 of file tpl_binNode.H.
Referenced by GenTdSplayTreeRk< NodeType, Key, Compare >::__insert(), GenTdSplayTree< NodeType, Key, Compare >::__insert(), Aleph::GenBinHeap< NodeType, Key, Compare >::__postorder_delete(), Aleph::__remove_by_pos_xt(), Aleph::__select_rec(), Aleph::__split_key_dup_rec_xt(), Aleph::__split_key_rec_xt(), Aleph::__split_pos_rec(), Aleph::GenBinHeap< NodeType, Key, Compare >::advance_left(), Aleph::GenBinHeap< NodeType, Key, Compare >::advance_right(), Aleph::BinNodeInfixIterator< Node >::advance_to_min(), Aleph::areEquivalents(), Aleph::areSimilar(), assign_arcs(), assign_distance(), assign_external_nodes(), assign_parrectangle(), assign_rectangle(), assign_triangle(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::balance_tree(), Aleph::HtdRbTree< Key, Compare >::balanceDownAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::balanceDownAndColor(), Aleph::bin_to_tree(), Aleph::bits_to_tree_helper(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::black_height(), Aleph::HtdRbTree< Key, Compare >::blackHeight(), Aleph::build_postorder(), Aleph::Huffman_Encoder_Engine::build_prefix_encoding(), Aleph::build_tree(), Aleph::callKeyDestructorsRec(), Aleph::check_bst_range(), Aleph::check_rank_tree(), Aleph::HtdRbTree< Key, Compare >::colorParentAndSibling(), Aleph::HtdRbTreeRk< Key, Compare >::colorParentAndSibling(), Aleph::GenTdRbTree< NodeType, Key, Compare >::colorRootAsRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::colorRootAsRed(), Aleph::compute_cardinality_rec(), Aleph::compute_nodes_in_level_helper(), Aleph::compute_tree(), Aleph::computeHeightRec(), Aleph::copyRec(), Aleph::Huffman_Decoder_Engine::decode(), Aleph::destroyRec(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::HtdRbTree< Key, Compare >::doubleRotateNephewAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::doubleRotateNephewAndColor(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::doubleRotateRight(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateRight(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::extract_max_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::extract_min_rb(), GenTdSplayTreeRk< NodeType, Key, Compare >::Iterator::find_min(), Aleph::find_min(), GenTdSplayTreeRk< NodeType, Key, Compare >::find_position(), Aleph::BinTreeXt_Operation< Node, Cmp >::find_position(), Aleph::find_position(), Aleph::find_predecessor(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::find_succ_and_swap(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::find_succ_and_swap(), Aleph::find_successor(), Aleph::GenTdRbTree< NodeType, Key, Compare >::findPredAndSwap(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::findPredAndSwap(), Aleph::HtdRbTree< Key, Compare >::findSuccAndSwap(), Aleph::HtdRbTreeRk< Key, Compare >::findSuccAndSwap(), Aleph::GenTdRbTree< NodeType, Key, Compare >::findSuccAndSwap(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::findSuccAndSwap(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_red_condition(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_red_condition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_red_violation(), Aleph::HtdRbTree< Key, Compare >::flipColors(), Aleph::HtdRbTreeRk< Key, Compare >::flipColors(), Aleph::GenTdRbTree< NodeType, Key, Compare >::flipColors(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::flipColors(), Aleph::For_Each_In_Order< Node >::for_each_inorder(), Aleph::forest_to_bin(), Aleph::Huffman_Encoder_Engine::generate_huffman_tree(), generate_tree(), Aleph::HtdRbTree< Key, Compare >::getSibling(), Aleph::HtdRbTreeRk< Key, Compare >::getSibling(), Aleph::GenTdRbTree< NodeType, Key, Compare >::getSibling(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoLeftAndColorRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::gotoLeftAndColorRed(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoRightAndColorRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::gotoRightAndColorRed(), Aleph::infix(), inorder_keys(), Aleph::BinTreeXt_Operation< Node, Cmp >::inorder_position(), Aleph::inorder_position(), Aleph::inorder_rec_helper(), GenTdSplayTreeRk< NodeType, Key, Compare >::Iterator::inorder_successor(), Aleph::inOrderThreaded(), Aleph::BinTree_Operation< Node, Cmp >::insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::insert(), GenTdSplayTreeRk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::GenBinHeap< NodeType, Key, Compare >::insert(), Aleph::HtdRbTree< Key, Compare >::insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::insert(), GenTdSplayTree< NodeType, Key, Compare >::insert(), Aleph::GenTdRbTree< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert(), Aleph::insert_by_key_xt(), Aleph::insert_by_pos_xt(), Aleph::BinTree_Operation< Node, Cmp >::insert_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::insert_dup(), GenTdSplayTreeRk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::HtdRbTree< Key, Compare >::insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::insert_dup(), GenTdSplayTree< NodeType, Key, Compare >::insert_dup(), Aleph::GenTdRbTree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert_dup(), Aleph::insert_dup_by_key_xt(), Aleph::insert_dup_in_bst(), Aleph::BinTree_Operation< Node, Cmp >::insert_dup_root(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_dup_root(), Aleph::insert_dup_root(), Aleph::insert_dup_root_xt(), Aleph::insert_in_bst(), Aleph::BinTree_Operation< Node, Cmp >::insert_root(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_root(), Aleph::insert_root(), Aleph::BinTree_Operation< Node, Cmp >::insert_root_rec(), Aleph::insert_root_rec(), Aleph::insert_root_xt(), Aleph::internal_path_length_helper(), is_avl(), Aleph::is_avl_rk(), Aleph::BinNodeInfixIterator< Node >::is_in_first(), Aleph::GenBinHeap< NodeType, Key, Compare >::is_in_list(), Aleph::is_leaf(), Aleph::is_red_black_rk(), Aleph::is_red_black_tree_rk(), Aleph::is_treap(), Aleph::Gen_Treap< NodeType, Key, Compare >::join(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join(), Aleph::BinTree_Operation< Node, Cmp >::join(), Aleph::join(), Aleph::Gen_Treap< NodeType, Key, Compare >::join_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::join_exclusive(), Aleph::Gen_Treap< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::join_exclusive_xt(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_left_rb(), Aleph::BinTree_Operation< Node, Cmp >::join_preorder(), Aleph::join_preorder(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_right_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_with_pivot_rb(), Aleph::BinNodePrefixIterator< Node >::last(), Aleph::level_traverse(), Aleph::levelOrder(), Aleph::Huffman_Encoder_Engine::load_leaf_keys_in_prefix(), Aleph::load_tree_keys_from_array(), Aleph::load_tree_keys_in_prefix(), Aleph::GenBinTree< NodeType, Key, Compare >::move_all(), Aleph::BinNodePrefixIterator< Node >::next_ne(), GenTdSplayTreeRk< NodeType, Key, Compare >::position(), Aleph::For_Each_Postorder< Node >::postorder(), Aleph::postorder_rec_helper(), Aleph::prefix(), Aleph::For_Each_Preorder< Node >::preorder(), Aleph::preorder_rec_helper(), Aleph::preorder_to_bst(), Aleph::preOrderThreaded(), Aleph::put_tree_keys_in_array(), RandTree< T >::random(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), random_tree(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::remove(), GenTdSplayTreeRk< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::remove(), GenTdSplayTree< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap< NodeType, Key, Compare >::remove(), Aleph::BinTree_Operation< Node, Cmp >::remove(), Aleph::Gen_Treap< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove(), Aleph::remove_by_key_xt(), Aleph::remove_from_bst(), Aleph::GenBinHeap< NodeType, Key, Compare >::remove_last(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove_pos(), Aleph::HtdRbTree< Key, Compare >::removeAndFixBlackCondition(), Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::removeAndRendLeafRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::removeAndRendLeafRed(), Aleph::GenBinHeap< NodeType, Key, Compare >::replace_node(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::restore_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::restore_avl_after_deletion(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_deletion(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::restore_avl_after_insertion(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl_after_insertion(), Aleph::HtdRbTree< Key, Compare >::restoreRedCondition(), Aleph::HtdRbTreeRk< Key, Compare >::restoreRedCondition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::restoreRedCondition(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::restoreRedCondition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_left_simple(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_right_simple(), Aleph::rotate_to_left(), Aleph::rotate_to_left(), Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_left_rk(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_to_left_rk(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::rotate_to_left_rk(), Aleph::rotate_to_left_xt(), Aleph::rotate_to_right(), Aleph::rotate_to_right(), Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_right_rk(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_to_right_rk(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::rotate_to_right_rk(), Aleph::rotate_to_right_xt(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::rotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateLeft(), Aleph::HtdRbTree< Key, Compare >::rotateNephewAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::rotateNephewAndColor(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::rotateRight(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateRight(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::rotation_type(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotation_type(), Aleph::Huffman_Encoder_Engine::save_leaf_keys_in_prefix(), Aleph::save_tree_keys_in_prefix(), Aleph::HtdRbTreeRk< Key, Compare >::search(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search(), Aleph::GenTdRbTree< NodeType, Key, Compare >::search(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::search(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search_and_stack_rb(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_and_stack_rb(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::search_dup_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_avl(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_rb(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search_dup_and_stack_rb(), Aleph::BinTree_Operation< Node, Cmp >::search_or_insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::HtdRbTree< Key, Compare >::search_or_insert(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search_or_insert(), Aleph::GenTdRbTree< NodeType, Key, Compare >::search_or_insert(), Aleph::search_or_insert_by_key_xt(), Aleph::search_or_insert_in_bst(), Aleph::BinTree_Operation< Node, Cmp >::search_or_insert_root_rec(), Aleph::search_or_insert_root_rec(), Aleph::search_or_insert_root_rec_xt(), Aleph::search_parent(), Aleph::search_rank_parent(), Aleph::HtdRbTree< Key, Compare >::searchAndBuildPath(), Aleph::HtdRbTreeRk< Key, Compare >::searchAndBuildPath(), Aleph::GenTdRbTree< NodeType, Key, Compare >::searchAndColorRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::searchAndColorRed(), Aleph::HtdRbTree< Key, Compare >::searchFlipColorsAndInsert(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), Aleph::GenTdRbTree< NodeType, Key, Compare >::searchFlipColorsAndInsert(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::searchFlipColorsAndInsert(), Aleph::HtdRbTree< Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::GenTdRbTree< NodeType, Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::searchInBinTree(), select(), Aleph::select(), Aleph::select_gotoup_root(), Aleph::select_ne(), Aleph::GenBinHeap< NodeType, Key, Compare >::sift_down(), GenTdSplayTree< NodeType, Key, Compare >::splay_impl(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_impl(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::split_key(), Aleph::BinTree_Operation< Node, Cmp >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec(), Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_dup_rec(), Aleph::BinTree_Operation< Node, Cmp >::split_key_dup_rec_helper(), Aleph::split_key_dup_rec_helper(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec(), Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_rec(), Aleph::BinTree_Operation< Node, Cmp >::split_key_rec_helper(), Aleph::split_key_rec_helper(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_rec_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::split_pos_inorder(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos_rec(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos_rec_rb(), Aleph::suffix(), Aleph::swap_node_with_predecessor(), Aleph::swap_node_with_successor(), Aleph::GenBinHeap< NodeType, Key, Compare >::swap_root_with_last(), Aleph::GenBinHeap< NodeType, Key, Compare >::swap_with_parent(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::swapWithSuccessor(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::swapWithSuccessor(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::test_black_condition_rk(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), Aleph::GenTdRbTree< NodeType, Key, Compare >::testBlackHeight(), Aleph::HtdRbTree< Key, Compare >::testNode(), Aleph::GenTdRbTree< NodeType, Key, Compare >::testNode(), thread_tree(), Aleph::tree_to_bits(), Aleph::HtdRbTreeRk< Key, Compare >::updateCountRec(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::updateCountRec(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::updateCountsFromStack(), Aleph::GenTdRbTree< NodeType, Key, Compare >::verify(), Aleph::HtdRbTreeRk< Key, Compare >::verifyCountsRec(), and write_leaves().
Load and build a binary tree from a stream.
load_tree(input) reads the stream input and load a binary tree previously saved with save_tree().
| [in] | input | stream |
| bad_alloc | if there is no enough memory |
Definition at line 1224 of file tpl_binNodeUtils.H.
References Aleph::destroyRec(), Aleph::BitArray::load(), Aleph::load_tree_keys_in_prefix(), Aleph::maps(), Aleph::prefix(), and root().
|
inline |
Build a binary tree from two arrays.
load_tree_from_array(bits, num_bits, keys) takes a bit array bits of num_bits, whose values of unsigned char type contain the tree code. The code is therefore read and the tree is built. Afterward, the array keys is read and the values set to the nodes keys in preorder.
The functor Load_Key is used in order to set the node key from a array entry. Its structure must be as follows:
bool load_key(Node * p, const char * str)
The functor must take the string str, perform any needed transformation and set the key of node p. If load_key() returns true then it is assumed that the key was already set and the process advances to the next key. Otherwise, str continues to be the current key and the process advances to the next node. for the next node in the prefix path.
| [in] | bits | array where the tree code is stored |
| [in] | num_bits | number of bits to be read |
| [in] | keys | array where the keys in preorder are stored |
| bad_alloc | if there is no enough memory |
Definition at line 1357 of file tpl_binNodeUtils.H.
References Aleph::BitArray::load_from_array_of_chars(), Aleph::maps(), Aleph::prefix(), and root().
Load the keys stored in preorder from an input stream.
load_tree_keys_in_prefix(root, input) traverses recursively the tree root. For each visited node a key is loaded from the stream
| [in] | root | of tree |
| [in] | input | stream where are the keys in preorder |
| runtime_error | if the input stream fails |
Definition at line 1173 of file tpl_binNodeUtils.H.
References ah_runtime_error_if, Aleph::LLINK(), Aleph::load_tree_keys_in_prefix(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by Aleph::load_tree(), Aleph::load_tree_keys_in_prefix(), and TEST().
|
inlinenoexcept |
Compute the inorder position of a key.
| [in] | key | to be searched |
key is not in the tree, then first the first value is -1. Definition at line 537 of file tpl_rand_tree.H.
References Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::cmp, Aleph::inorder_position(), Aleph::maps(), and Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::tree_root.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Compute the inorder position of a key.
| [in] | key | to be searched |
key if this is in the tree or -1 if key is not found Definition at line 578 of file tpl_treapRk.H.
References Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::cmp, Aleph::inorder_position(), Aleph::maps(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::tree_root.
Traverse recursively in postorder a binary tree.
postOrderRec(root,visit) performs an inorder traversal of tree rooted by root and on each node executes a visit function with the following signature:
void (*visitFct)(Node* p, int level, int pos)
Where:
p: pointer to visited node.level: level of node p.pos: ordinal indicating the visit order
| [in] | root | pointer to tree's root |
| [in] | visitFct | pointer to visit function |
Definition at line 189 of file tpl_binNodeUtils.H.
References Aleph::maps(), Aleph::postorder_rec_helper(), and root().
Return a list with preorder traversal of a tree.
| [in] | root | of tree |
| bad_alloc | if there is no enough memory |
Definition at line 433 of file tpl_binNodeUtils.H.
References Aleph::maps(), Aleph::prefix(), and root().
Traverse a tree in preorder via its iterator and performs a conditioned operation on each item.
prefix_traverse(root, operation) instantiates the internal iterator of the class and traverses each item performing operation(p), where p is a node pointer.
operation must have the following signature:
bool operation(Node * p)
If operation(p) returns true then the iterator is advanced and the next item processed. Otherwise. the traversal stops.
| root | ||
| [in] | op | to be performed on each item |
true if all the nodes were visited (operation on each one always returned true) or false if the traversal was stopped because there was a false result on an item. | anything | that could throw operation |
Definition at line 2641 of file tpl_binNodeUtils.H.
References Aleph::BinNodePrefixIterator< Node >::has_curr(), Aleph::maps(), and root().
|
inline |
Build a binary search tree from its preorder traversal.
| [in] | preorder | dynamic array where the preorder traversal is found |
| [in] | l | lower index |
| [in] | r | upper index |
| cmp | comparison criteria |
| bad_alloc | if there is no enough memory |
Definition at line 1422 of file tpl_binNodeUtils.H.
References cmp(), l, Aleph::LLINK(), Aleph::maps(), preorder(), Aleph::RLINK(), and root().
Traverse recursively in preorder a binary tree.
preOrderRec(root,visit) performs a preorder traversal of tree rooted by root and on each node executes a visit function with the following signature:
void (*visitFct)(Node* p, int level, int pos)
Where:
p: pointer to visited node.level: level of node p.pos: ordinal indicating the visit order
| [in] | root | pointer to tree's root |
| [in] | visitFct | pointer to visit function |
Definition at line 143 of file tpl_binNodeUtils.H.
References Aleph::maps(), Aleph::preorder_rec_helper(), and root().
Referenced by build_tree(), Aleph::DynSetTree< Key, Tree, Compare >::for_each_in_preorder(), huffman_to_btreepic(), main(), main(), Aleph::HtdRbTree< Key, Compare >::verifyRedBlack(), write_avl(), write_bin(), write_rand(), write_rb(), write_splay(), and write_treap().
Traverse preorder a binary tree without recursion and without stack.
preOrderThreaded(root,visit) traverses preorder the binary tree by building partial threads to successor nodes. This implicates that during the traversal the links could be invalid.
The visit function has the following signature:
void (*visitFct)(Node* p, int level, int pos)
Where:
p: pointer to the currently visited nodelevel: the level of visited node| [in] | node | of tree |
| [in] | visitFct | pointer to visit function |
Definition at line 947 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by TEST().
Access the priority of a treap node.
| Node | Treap node type |
| p | Pointer to node |
Definition at line 120 of file treapNode.H.
Referenced by Aleph::Gen_Treap< NodeType, Key, Compare >::init(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::init(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert_dup(), Aleph::is_treap(), Aleph::Gen_Treap< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Treap< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search_or_insert(), and TEST_F().
|
inlinenoexcept |
Remove a key of extended binary tree.
remove_by_key_xt(root, key, cmp) searches in the extended binary tree root the key. If key is found, then the node containing it is removed from the tree.
| [in,out] | root | of tree |
| [in] | key | to search and eventually to remove |
| [in] | cmp | comparison criteria |
Node::NullPtrDefinition at line 817 of file tpl_binNodeXt.H.
References cmp(), Aleph::COUNT(), Aleph::join_exclusive_xt(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::remove_by_key_xt(), Aleph::HTList::reset(), Aleph::RLINK(), and root().
Referenced by Aleph::remove_by_key_xt(), Aleph::remove_by_key_xt(), TEST(), and TEST().
Remove from a extended binary tree the node whose inorder position is pos.
| [in,out] | root | of tree |
| [in] | pos | iorder position of node to be removed |
| out_of_range | if pos is greater than the number of nodes of tree |
Definition at line 895 of file tpl_binNodeXt.H.
References Aleph::__remove_by_pos_xt(), ah_out_of_range_error_if, Aleph::COUNT(), and root().
|
inlinenoexcept |
Remove a key from a binary search tree.
| [in,out] | root | of tree |
| [in] | key | to remove |
| [in] | cmp | comparison criteria |
key was found in the tree, Node::NullPtr otherwiseDefinition at line 1955 of file tpl_binNodeUtils.H.
References cmp(), Aleph::join_exclusive(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::remove_from_bst(), Aleph::HTList::reset(), Aleph::RLINK(), and root().
Referenced by Aleph::join(), Aleph::remove_from_bst(), TEST(), and TEST().
Return the right tree of p.
Definition at line 338 of file tpl_binNode.H.
Referenced by Aleph::GenTdRbTree< NodeType, Key, Compare >::GenTdRbTree(), Aleph::HtdRbTree< Key, Compare >::HtdRbTree(), Aleph::HtdRbTree< Key, Compare >::HtdRbTree(), GenTdSplayTreeRk< NodeType, Key, Compare >::__insert(), GenTdSplayTree< NodeType, Key, Compare >::__insert(), Aleph::GenBinHeap< NodeType, Key, Compare >::__postorder_delete(), Aleph::__remove_by_pos_xt(), Aleph::__select_rec(), Aleph::__split_key_dup_rec_xt(), Aleph::__split_key_rec_xt(), Aleph::__split_pos_rec(), Aleph::GenBinHeap< NodeType, Key, Compare >::advance_right(), Aleph::BinNodeInfixIterator< Node >::advance_to_max(), Aleph::areEquivalents(), Aleph::areSimilar(), assign_arcs(), assign_distance(), assign_external_nodes(), assign_parrectangle(), assign_rectangle(), assign_triangle(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::avl_height(), Aleph::balance_tree(), Aleph::HtdRbTree< Key, Compare >::balanceDownAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::balanceDownAndColor(), Aleph::bin_to_tree(), Aleph::bits_to_tree_helper(), Aleph::HtdRbTree< Key, Compare >::blackHeight(), Aleph::build_postorder(), Aleph::Huffman_Encoder_Engine::build_prefix_encoding(), Aleph::build_tree(), Aleph::callKeyDestructorsRec(), Aleph::check_bst_range(), Aleph::check_rank_tree(), Aleph::HtdRbTree< Key, Compare >::colorParentAndSibling(), Aleph::HtdRbTreeRk< Key, Compare >::colorParentAndSibling(), Aleph::GenTdRbTree< NodeType, Key, Compare >::colorRootAsRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::colorRootAsRed(), Aleph::compute_cardinality_rec(), Aleph::compute_nodes_in_level_helper(), Aleph::compute_tree(), Aleph::computeHeightRec(), Aleph::copyRec(), Aleph::Huffman_Decoder_Engine::decode(), Aleph::destroyRec(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateLeft(), Aleph::HtdRbTree< Key, Compare >::doubleRotateNephewAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::doubleRotateNephewAndColor(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::doubleRotateRight(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::doubleRotateRight(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_max(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::extract_max_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::extract_min(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::extract_min_rb(), Aleph::find_max(), Aleph::BinTreeXt_Operation< Node, Cmp >::find_position(), Aleph::find_position(), Aleph::find_predecessor(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::find_succ_and_swap(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::find_succ_and_swap(), Aleph::find_successor(), Aleph::GenTdRbTree< NodeType, Key, Compare >::findPredAndSwap(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::findPredAndSwap(), Aleph::HtdRbTree< Key, Compare >::findSuccAndSwap(), Aleph::HtdRbTreeRk< Key, Compare >::findSuccAndSwap(), Aleph::GenTdRbTree< NodeType, Key, Compare >::findSuccAndSwap(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::findSuccAndSwap(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_red_condition(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_red_condition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::fix_red_violation(), Aleph::HtdRbTree< Key, Compare >::flipColors(), Aleph::HtdRbTreeRk< Key, Compare >::flipColors(), Aleph::GenTdRbTree< NodeType, Key, Compare >::flipColors(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::flipColors(), Aleph::For_Each_In_Order< Node >::for_each_inorder(), Aleph::forest_to_bin(), Aleph::Huffman_Encoder_Engine::generate_huffman_tree(), generate_tree(), Aleph::HtdRbTree< Key, Compare >::getSibling(), Aleph::HtdRbTreeRk< Key, Compare >::getSibling(), Aleph::GenTdRbTree< NodeType, Key, Compare >::getSibling(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoLeftAndColorRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::gotoLeftAndColorRed(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoRightAndColorRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::gotoRightAndColorRed(), Aleph::GenBinHeap< NodeType, Key, Compare >::has_sibling(), Aleph::infix(), Aleph::HtdRbTreeRk< Key, Compare >::init(), Aleph::GenTdRbTree< NodeType, Key, Compare >::init(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::init(), inorder_keys(), Aleph::BinTreeXt_Operation< Node, Cmp >::inorder_position(), Aleph::inorder_position(), Aleph::inorder_rec_helper(), GenTdSplayTreeRk< NodeType, Key, Compare >::Iterator::inorder_successor(), Aleph::inOrderThreaded(), Aleph::BinTree_Operation< Node, Cmp >::insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::insert(), GenTdSplayTreeRk< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert(), Aleph::GenBinHeap< NodeType, Key, Compare >::insert(), Aleph::HtdRbTree< Key, Compare >::insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::insert(), GenTdSplayTree< NodeType, Key, Compare >::insert(), Aleph::GenTdRbTree< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert(), Aleph::insert_by_key_xt(), Aleph::insert_by_pos_xt(), Aleph::BinTree_Operation< Node, Cmp >::insert_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::insert_dup(), GenTdSplayTreeRk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::HtdRbTree< Key, Compare >::insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::insert_dup(), GenTdSplayTree< NodeType, Key, Compare >::insert_dup(), Aleph::GenTdRbTree< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert_dup(), Aleph::insert_dup_by_key_xt(), Aleph::insert_dup_in_bst(), Aleph::BinTree_Operation< Node, Cmp >::insert_dup_root(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_dup_root(), Aleph::insert_dup_root(), Aleph::insert_dup_root_xt(), Aleph::insert_in_bst(), Aleph::BinTree_Operation< Node, Cmp >::insert_root(), Aleph::BinTreeXt_Operation< Node, Cmp >::insert_root(), Aleph::insert_root(), Aleph::BinTree_Operation< Node, Cmp >::insert_root_rec(), Aleph::insert_root_rec(), Aleph::insert_root_xt(), Aleph::internal_path_length_helper(), is_avl(), Aleph::is_avl_rk(), Aleph::GenBinHeap< NodeType, Key, Compare >::is_in_list(), Aleph::BinNodeInfixIterator< Node >::is_last(), Aleph::is_leaf(), Aleph::is_red_black_rk(), Aleph::is_red_black_tree_rk(), Aleph::is_treap(), Aleph::Gen_Treap< NodeType, Key, Compare >::join(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join(), Aleph::BinTree_Operation< Node, Cmp >::join(), Aleph::join(), Aleph::Gen_Treap< NodeType, Key, Compare >::join_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::join_exclusive(), Aleph::Gen_Treap< NodeType, Key, Compare >::join_exclusive(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::join_exclusive(), Aleph::join_exclusive_xt(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_left(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_left_rb(), Aleph::BinTree_Operation< Node, Cmp >::join_preorder(), Aleph::join_preorder(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_right(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_right_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::join_with_pivot(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::join_with_pivot_rb(), Aleph::BinNodePrefixIterator< Node >::last(), Aleph::level_traverse(), Aleph::levelOrder(), Aleph::Huffman_Encoder_Engine::load_leaf_keys_in_prefix(), Aleph::load_tree_keys_from_array(), Aleph::load_tree_keys_in_prefix(), Aleph::GenBinTree< NodeType, Key, Compare >::move_all(), Aleph::BinNodePrefixIterator< Node >::next_ne(), Aleph::BinNodeInfixIterator< Node >::next_ne(), Aleph::For_Each_Postorder< Node >::postorder(), Aleph::postorder_rec_helper(), Aleph::prefix(), Aleph::For_Each_Preorder< Node >::preorder(), Aleph::preorder_rec_helper(), Aleph::preorder_to_bst(), Aleph::preOrderThreaded(), Aleph::put_tree_keys_in_array(), RandTree< T >::random(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_insert_dup(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_join_exclusive(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_remove(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::random_search_or_insert(), random_tree(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::remove(), GenTdSplayTreeRk< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::remove(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::remove(), GenTdSplayTree< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap< NodeType, Key, Compare >::remove(), Aleph::BinTree_Operation< Node, Cmp >::remove(), Aleph::Gen_Treap< NodeType, Key, Compare >::remove(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove(), Aleph::remove_by_key_xt(), Aleph::remove_from_bst(), Aleph::GenBinHeap< NodeType, Key, Compare >::remove_last(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::remove_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove_pos(), Aleph::HtdRbTree< Key, Compare >::removeAndFixBlackCondition(), Aleph::HtdRbTreeRk< Key, Compare >::removeAndFixBlackCondition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::removeAndRendLeafRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::removeAndRendLeafRed(), Aleph::GenBinHeap< NodeType, Key, Compare >::replace_node(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::restore_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::restore_avl(), Aleph::HtdRbTree< Key, Compare >::restoreRedCondition(), Aleph::HtdRbTreeRk< Key, Compare >::restoreRedCondition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::restoreRedCondition(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::restoreRedCondition(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_left_simple(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_right_simple(), Aleph::rotate_to_left(), Aleph::rotate_to_left(), Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_left_rk(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_to_left_rk(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::rotate_to_left_rk(), Aleph::rotate_to_left_xt(), Aleph::rotate_to_right(), Aleph::rotate_to_right(), Aleph::HtdRbTreeRk< Key, Compare >::rotate_to_right_rk(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::rotate_to_right_rk(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::rotate_to_right_rk(), Aleph::rotate_to_right_xt(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::rotateLeft(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateLeft(), Aleph::HtdRbTree< Key, Compare >::rotateNephewAndColor(), Aleph::HtdRbTreeRk< Key, Compare >::rotateNephewAndColor(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::rotateRight(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotateRight(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::rotation_type(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::rotation_type(), Aleph::Huffman_Encoder_Engine::save_leaf_keys_in_prefix(), Aleph::save_tree_keys_in_prefix(), Aleph::HtdRbTreeRk< Key, Compare >::search(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search(), Aleph::GenTdRbTree< NodeType, Key, Compare >::search(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::search(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_and_stack_avl(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search_and_stack_rb(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_and_stack_rb(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::search_dup_and_stack_avl(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_avl(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_dup_and_stack_rb(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search_dup_and_stack_rb(), Aleph::BinTree_Operation< Node, Cmp >::search_or_insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::search_or_insert(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::HtdRbTree< Key, Compare >::search_or_insert(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::search_or_insert(), Aleph::GenTdRbTree< NodeType, Key, Compare >::search_or_insert(), Aleph::search_or_insert_by_key_xt(), Aleph::search_or_insert_in_bst(), Aleph::BinTree_Operation< Node, Cmp >::search_or_insert_root_rec(), Aleph::search_or_insert_root_rec(), Aleph::search_or_insert_root_rec_xt(), Aleph::search_parent(), Aleph::search_rank_parent(), Aleph::HtdRbTree< Key, Compare >::searchAndBuildPath(), Aleph::HtdRbTreeRk< Key, Compare >::searchAndBuildPath(), Aleph::GenTdRbTree< NodeType, Key, Compare >::searchAndColorRed(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::searchAndColorRed(), Aleph::HtdRbTree< Key, Compare >::searchFlipColorsAndInsert(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsert(), Aleph::GenTdRbTree< NodeType, Key, Compare >::searchFlipColorsAndInsert(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::searchFlipColorsAndInsert(), Aleph::HtdRbTree< Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::HtdRbTreeRk< Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::GenTdRbTree< NodeType, Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::searchFlipColorsAndInsertDup(), Aleph::searchInBinTree(), select(), Aleph::select(), Aleph::select_gotoup_root(), Aleph::select_ne(), Aleph::GenBinHeap< NodeType, Key, Compare >::sift_down(), GenTdSplayTree< NodeType, Key, Compare >::splay_impl(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_impl(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_max(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key(), Aleph::split_key(), Aleph::BinTree_Operation< Node, Cmp >::split_key(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec(), Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_dup_rec(), Aleph::BinTree_Operation< Node, Cmp >::split_key_dup_rec_helper(), Aleph::split_key_dup_rec_helper(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_dup_rec_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_key_rec(), Aleph::BinTreeXt_Operation< Node, Cmp >::split_key_rec(), Aleph::BinTree_Operation< Node, Cmp >::split_key_rec_helper(), Aleph::split_key_rec_helper(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_key_rec_rb(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::split_pos_inorder(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::split_pos_rec(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::split_pos_rec_rb(), Aleph::suffix(), Aleph::swap_node_with_predecessor(), Aleph::swap_node_with_successor(), Aleph::GenBinHeap< NodeType, Key, Compare >::swap_root_with_last(), Aleph::GenBinHeap< NodeType, Key, Compare >::swap_with_parent(), Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::swapWithSuccessor(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::swapWithSuccessor(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), Aleph::test_black_condition_rk(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), Aleph::GenTdRbTree< NodeType, Key, Compare >::testBlackHeight(), Aleph::HtdRbTree< Key, Compare >::testNode(), Aleph::GenTdRbTree< NodeType, Key, Compare >::testNode(), thread_tree(), Aleph::tree_to_bits(), Aleph::HtdRbTreeRk< Key, Compare >::updateCountRec(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::updateCountRec(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::updateCountsFromStack(), Aleph::GenTdRbTree< NodeType, Key, Compare >::verify(), Aleph::HtdRbTreeRk< Key, Compare >::verifyCountsRec(), and write_leaves().
Rotate to the left the tree with root p
| [in] | p | root to rotate |
Definition at line 2159 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::HtdRbTree< Key, Compare >::balanceDownAndColor(), Aleph::HtdRbTree< Key, Compare >::doubleRotateNephewAndColor(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_red_condition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoLeftAndColorRed(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoRightAndColorRed(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert_dup(), Aleph::BinTree_Operation< Node, Cmp >::insert_root_rec(), Aleph::insert_root_rec(), Aleph::Gen_Treap< NodeType, Key, Compare >::remove(), Aleph::HtdRbTree< Key, Compare >::restoreRedCondition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::restoreRedCondition(), Aleph::HtdRbTree< Key, Compare >::rotateNephewAndColor(), Aleph::Gen_Treap< NodeType, Key, Compare >::search_or_insert(), Aleph::BinTree_Operation< Node, Cmp >::search_or_insert_root_rec(), Aleph::search_or_insert_root_rec(), GenTdSplayTree< NodeType, Key, Compare >::splay_impl(), and TEST().
Rotate to the left the tree with root p and update its parent.
| [in] | p | root to rotate |
| pp | parent of p |
Definition at line 2178 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Rotate to left the extended binary tree with root p.
| [in] | p | root to rotate. |
Definition at line 946 of file tpl_binNodeXt.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::search_or_insert_root_rec_xt(), Aleph::select_gotoup_root(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_impl(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_max(), and TEST().
Rotate to the right the tree with root p
| [in] | p | root to rotate |
Definition at line 2114 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::HtdRbTree< Key, Compare >::balanceDownAndColor(), Aleph::HtdRbTree< Key, Compare >::doubleRotateNephewAndColor(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_black_condition(), Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::fix_red_condition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoLeftAndColorRed(), Aleph::GenTdRbTree< NodeType, Key, Compare >::gotoRightAndColorRed(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap< NodeType, Key, Compare >::insert_dup(), Aleph::BinTree_Operation< Node, Cmp >::insert_root_rec(), Aleph::insert_root_rec(), Aleph::Gen_Treap< NodeType, Key, Compare >::remove(), Aleph::HtdRbTree< Key, Compare >::restoreRedCondition(), Aleph::GenTdRbTree< NodeType, Key, Compare >::restoreRedCondition(), Aleph::HtdRbTree< Key, Compare >::rotateNephewAndColor(), Aleph::Gen_Treap< NodeType, Key, Compare >::search_or_insert(), Aleph::BinTree_Operation< Node, Cmp >::search_or_insert_root_rec(), Aleph::search_or_insert_root_rec(), GenTdSplayTree< NodeType, Key, Compare >::splay_impl(), and TEST().
Rotate to the right the tree with root p and update its parent.
| [in] | p | root to rotate |
| [in] | pp | parent of p |
Definition at line 2134 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Rotate to right the extended bianry tree with root p
| [in] | p | root to rotate |
Definition at line 925 of file tpl_binNodeXt.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::insert_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search_or_insert(), Aleph::search_or_insert_root_rec_xt(), Aleph::select_gotoup_root(), GenTdSplayTreeRk< NodeType, Key, Compare >::splay_impl(), and TEST().
Store a binary tree in a stream.
save_tree(root, output) saves the binary tree with root in the stream output. The tree could be restored through load_tree().
The operator << must overload for the key of node.
| [in] | root | of tree |
| [out] | output | stream |
| bad_alloc | if there is no enough memory |
Definition at line 1202 of file tpl_binNodeUtils.H.
References output, Aleph::prefix(), root(), Aleph::save_tree_keys_in_prefix(), and Aleph::tree_to_bits().
Referenced by TEST().
|
inline |
Generate C++ array declarations for a binary tree.
save_tree_in_array_of_chars(root, array_name, output) generates two array declarations that would allow to restore the original binary tree. The generated declarations would have the following form:
const unsigned char array_name_cdp[n] = { unsigned char list };
const char * array_name_k[] = { key in prefix order };
The first array is a bit array containing the tree code (its Lukasiewicz word). The second array contains a strinficted version of the key values that were generated through the functor Get_Key, whose structure must be as follows:
std::string get_key(Node * p);
The goodness of this function is to embed binary trees in C++ source code.
| [in] | root | of tree |
| [in] | array_name | prefix name to be added to array variables. |
| [out] | output | stream where the arrays should be written |
Definition at line 1313 of file tpl_binNodeUtils.H.
References Aleph::maps(), output, Aleph::prefix(), root(), and Aleph::tree_to_bits().
Store in output stream the tree keys in preorder.
save_tree_keys_in_prefix(root, output) traverses recursively the tree in preorder. For each node, it saves in the stream its key.
Each visit call to functor Get_Key whose function is to extract and return a stringficated version of the key. Its signature must be as follows:
std::string gk(Node * p)
| [in] | root | of tree |
| [out] | output | stream |
Definition at line 1150 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), output, Aleph::RLINK(), root(), and Aleph::save_tree_keys_in_prefix().
Referenced by Aleph::save_tree(), and Aleph::save_tree_keys_in_prefix().
|
inline |
Searches key in a forest and computes the Dewey number of the node containing the key.
search_deway(root,key,deway,n) searches in the forest whose first tree is root a node containing the key. If the node is found, then the routine stores in deway[] the Dewey number of the found node.
The search is performed using the equality criterion Equal()().
| [in] | root | root of the first tree of the forest. |
| [in] | key | key to search. |
| [out] | deway | array that stores the Dewey number. |
| [in] | size | maximum length of the Dewey number. |
| [out] | n | length of the computed Dewey number (if the node is found). |
| overflow_error | if size is not sufficient to store the Dewey sequence. |
Definition at line 1146 of file tpl_tree_node.H.
References ah_overflow_error_if, deway(), Aleph::maps(), root(), and Aleph::size().
Referenced by TEST_F().
|
inlinenoexcept |
Search or insert a node in a binary search tree.
search_or_insert_in_bst(root, p, cmp) searches in root a node containing p->get_key(). If found, then this node is returned. Otherwise, p is inserted and returned.
| [in,out] | r | roor of tree |
| [in] | p | node to search or insert |
| [in] | cmp | comparison criteria |
p if its key was not in the tree; otherwise, a pointer containing the tree is returned. Definition at line 1778 of file tpl_binNodeUtils.H.
References cmp(), KEY, Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by TEST().
|
inlinenoexcept |
Search and eventually insert p as root in a binary search tree.
| [in] | root | of tree |
| [in] | p | pointer to the node to eventually insert |
| [in] | cmp | comparison criteria |
p is inserted, then it returns p; otherwise, it returns a pointer to the tree node containing to p->get_key() Definition at line 2434 of file tpl_binNodeUtils.H.
References cmp(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), root(), Aleph::rotate_to_left(), Aleph::rotate_to_right(), and Aleph::search_or_insert_root_rec().
Referenced by Aleph::search_or_insert_root_rec().
|
inlinenoexcept |
Search a key and find its node and parent.
| [in] | root | of tree |
| [in] | key | to search |
| [out] | parent | pointer to parent node if key was found. Otherwise, value is undetermined |
| [in] | cmp | comparison criteria |
key if this is found; otherwise, it returns a pointer to the last visited node Definition at line 1625 of file tpl_binNodeUtils.H.
References cmp(), Aleph::CmpGreater, Aleph::CmpLess, KEY, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), root(), and Aleph::three_way_compare().
Referenced by TEST().
|
inlinenoexcept |
Rank search of a key in a binary search tree.
In a binary search tree the rank search of a key consists in determining the node that would be parent of key.
search_rank_parent(root, key) searches a node containing key. If key is found, then its node is returned. Otherwise, the last visited node, that would be the parent of key if this was inserted in the tree, is returned.
| [in] | root | of general tree |
| [in] | key | to search |
key if this node exists or the last visited node otherwise Definition at line 120 of file tpl_binTreeOps.H.
References Aleph::BinTree_Operation< Node, Cmp >::cmp, Aleph::maps(), and root().
|
inlinenoexcept |
Rank search of a key in a binary search tree.
In a binary search tree the rank search of a key consists in determining the node that would be parent of key.
search_rank_parent(root, key, cmp) searches a node containing key. If key is found, then its node is returned. Otherwise, the last visited node, that would be the parent of key if this was inserted in the tree, is returned.
| [in] | root | of general tree |
| [in] | key | to search |
| [in] | cmp | comparison criteria |
key if this node exists or the last visited node otherwise Definition at line 1676 of file tpl_binNodeUtils.H.
References cmp(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by TEST().
|
inlinenoexcept |
Search a key in a binary search tree.
| [in] | root | of tree |
| [in] | key | to search |
| [in] | cmp | key comparison criteria |
Node::NullPtr otherwise Search a key in a binary search tree using optimistic search.Uses single comparison per level with deferred duplicate detection, reducing comparisons from ~1.5h to h+1 for tree height h.
Definition at line 1492 of file tpl_binNodeUtils.H.
References cmp(), KEY, Aleph::LLINK(), Aleph::maps(), Aleph::next(), Aleph::RLINK(), and root().
Referenced by main(), Aleph::HtdRbTree< Key, Compare >::search(), Aleph::Gen_Treap< NodeType, Key, Compare >::search(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::search(), Aleph::BinTree_Operation< Node, Cmp >::search(), and TEST().
Iterative selection of a node according to inorder position.
| [in] | r | root of tree |
| [in] | pos | position inorder whose node wants to be located |
| out_of_range | if pos is greater or equal than the number of nodes. |
Definition at line 164 of file tpl_binNodeXt.H.
References ah_out_of_range_error_if, Aleph::COUNT(), and Aleph::select_ne().
Referenced by main(), GenTdSplayTreeRk< NodeType, Key, Compare >::select(), Aleph::Gen_Avl_Tree_Rk< NodeType, Key, Compare >::select(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::select(), Aleph::Gen_Rb_Tree_Rk< NodeType, Key, Compare >::select(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::select(), Aleph::HtdRbTreeRk< Key, Compare >::select(), Aleph::GenTdRbTreeRk< NodeType, Key, Compare >::select(), TEST(), TEST(), TEST(), TEST(), Aleph::BinTreeXt_Iterator< TreeType, Node, Key, Compare >::update_curr(), and Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::Iterator::update_curr().
Selecciona un nodo de un Ă¡rbol binario segĂºn su posiciĂ³n infija y lo convierte en su raĂz.
select_gotoup_root(r,i) selecciona el nodo con posiciĂ³n infija i y lo rota hasta que Ă©ste devenga su raĂz.
Este algoritmo de selecciĂ³n es recursivo.
| [in] | root | raĂz del Ă¡rbol binario con rangos. |
| [in] | i | posiciĂ³n infija que se desea acceder. |
| out_of_range | si i es mayor o igual que la cantidad total de nodos del Ă¡rbol binario. |
Definition at line 72 of file tpl_balanceXt.H.
References ah_out_of_range_error_if, Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), root(), Aleph::rotate_to_left_xt(), Aleph::rotate_to_right_xt(), and Aleph::select_gotoup_root().
Referenced by Aleph::balance_tree(), and Aleph::select_gotoup_root().
Iterative selection of a node according to inorder position without exception.
| [in] | r | root of tree |
| [in] | pos | position inorder whose node wants to be located |
Definition at line 132 of file tpl_binNodeXt.H.
References Aleph::COUNT(), Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by Aleph::select(), and TEST().
Recursively select the i-th node inorder sense.
| [in] | r | root of tree |
| [in] | i | position inorder sense |
| out_of_range | if i is greater or equal than the number of nodes of overall tree |
Definition at line 114 of file tpl_binNodeXt.H.
References Aleph::__select_rec(), ah_out_of_range_error_if, and Aleph::COUNT().
|
inlinenoexcept |
Split a binary search tree according to a key.
split_key(root, key, l, r, cmp) splits the tree root according to key. At the end, l contains all the keys lesser than key and r all the keys greater or equal than key.
| [in,out] | root | of tree to split |
| [in] | key | for splitting |
| [out] | l | tree with keys lesser than key |
| [out] | r | tree with keys greater or equal than key |
| [in] | cmp | comparison criteria |
Definition at line 2214 of file tpl_binNodeUtils.H.
References cmp(), KEY, l, Aleph::LLINK(), Aleph::maps(), Aleph::RLINK(), and root().
Referenced by TEST().
|
inlinenoexcept |
Split a tree according to a key value.
split_key_dup_rec(root, key, ts, tg, cmp) splits according to key the tree withrootand build two trees.t1contains the keys lesser thankeyandt2the keys greater or equal thankey`.
| [in,out] | root | of tre to be split |
| [in] | key | for splitting |
| [out] | ts | tree with the keys lesser than key |
| [out] | tg | tree with the keys greater or equal than key |
| [in] | cmp | comparison criteria |
Definition at line 1901 of file tpl_binNodeUtils.H.
References cmp(), Aleph::maps(), root(), and Aleph::split_key_dup_rec_helper().
Referenced by Aleph::insert_dup_root(), Aleph::Gen_Treap< NodeType, Key, Compare >::split_key_dup(), and TEST().
|
inlinenoexcept |
Split an extended binary search tree according to a key which can be in the tree.
split_key__dup_rec_xt(root, key, l, r, cmp) splits a tree according a key. The key can be in the tree.
| [in,out] | root | pointer to tree root |
| [in] | key | for splitting |
| [out] | l | tree with keys lesser than key |
| [out] | r | tree with keys greater than key |
| [in] | cmp | comparison criteria |
Definition at line 583 of file tpl_binNodeXt.H.
References cmp(), l, Aleph::maps(), and root().
Referenced by Aleph::insert_dup_root_xt(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::split_key_dup(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::split_key_dup(), Aleph::split_key_dup_rec_xt(), and TEST().
|
inlinenoexcept |
Split recursively according to a key.
split_key_rec(root, key, ts, tg, cmp) splits the tree with root in two trees t1 which contain the keys lesser than key and t2 which contains the keys greater than key.
The split only is performed if key is not in the tree.
| [in,out] | root | of tree |
| [in] | key | for slitting |
| [out] | ts | tree with keys lesser than key |
| [out] | tg | tree with keys greater than key |
| [in] | cmp | comparison criteria |
true if the tree wa split; that if key was not in the tree. Otherwise, the split is not performed and it return falseDefinition at line 1850 of file tpl_binNodeUtils.H.
References cmp(), Aleph::maps(), root(), and Aleph::split_key_rec_helper().
Referenced by Aleph::insert_root(), Aleph::GenBinTree< NodeType, Key, Compare >::split(), Aleph::Gen_Treap< NodeType, Key, Compare >::split_key(), and TEST().
|
inlinenoexcept |
Split an extended binary search tree according to a key.
split_key_rec_xt(root, key, l, r, cmp) splits a tree according a non-existing key
| [in,out] | root | pointer to tree root |
| [in] | key | for splitting |
| [out] | l | tree with keys lesser than key |
| [out] | r | tree with keys greater than key |
| [in,out] | cmp | comparison function |
true if tree was split; that is if key is not in the tree. Otherwise, if key is in the tree, false is returned Definition at line 523 of file tpl_binNodeXt.H.
References Aleph::__split_key_rec_xt(), cmp(), l, Aleph::maps(), and root().
Referenced by Aleph::insert_root_xt(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::split_key(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::split_key(), Aleph::split_key_rec_xt(), TEST(), and TEST().
Split a extended binary tree according to a position.
split_pos_rec(r, i, ts, tg) splits the tree with root r en two trees ts and tg according to a position i. ts contains the keys from 0 to i - 1 inorder sense and tg the keys from i to n - 1. After completion the original tree r becames empty.
| [in,out] | r | pointer to the root of tree |
| [in] | i | position for splitting |
| [out] | ts | tree where the rank of keys \([0, i)\) will be put |
| [out] | tg | tree where the rank of keys \([i, n]\) will be put |
Definition at line 725 of file tpl_binNodeXt.H.
References ah_out_of_range_error_if, Aleph::COUNT(), and Aleph::maps().
Referenced by Aleph::insert_by_pos_xt(), main(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::remove(), Aleph::Gen_Rand_Tree< NodeType, Key, Compare >::split_pos(), Aleph::Gen_Treap_Rk< NodeType, Key, Compare >::split_pos(), TEST(), and TEST().
Return a list with postorder traversal of a tree.
| [in] | root | of tree |
| bad_alloc | if there is no enough memory |
Definition at line 463 of file tpl_binNodeUtils.H.
References Aleph::maps(), root(), and Aleph::suffix().
|
inlinenoexcept |
Swap a node with its predecessor inorder.
| [in] | p | pointer to node to swap with predecessor |
| [in,out] | pp | parent of p |
| [in] | q | predecessor of p |
| [in,out] | pq | parent of q |
Definition at line 2333 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Swap a node with its successor inorder.
| [in] | p | pointer to node to swap with successor |
| [in,out] | pp | parent of p |
| [in] | q | successor of p |
| [in,out] | pq | parent of q |
Definition at line 2279 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
|
inlinenoexcept |
Three-way comparison using a binary comparator.
Returns CmpLess if a < b, CmpEqual if a == b, CmpGreater if a > b. This reduces two comparisons to one when the result is cached.
| [in] | a | first value to compare |
| [in] | b | second value to compare |
| [in] | cmp | binary less-than comparator |
Definition at line 1465 of file tpl_binNodeUtils.H.
References cmp(), Aleph::CmpEqual, Aleph::CmpGreater, and Aleph::CmpLess.
Referenced by Aleph::search_parent().
Postorder traversal of a tree.
tree_postorder_traversal((root,visit) performs a postorder traversal over the tree rooted at root. If visitFct is specified, then for each visited node the function is invoked.
The visit function has the following specification:
void (visitFct)(Node p, int level, int pos)
Where:
| [in] | root | root of the tree to traverse. |
| [in] | visitFct | pointer to the visit function. |
Definition at line 915 of file tpl_tree_node.H.
References Aleph::__tree_postorder_traversal(), Aleph::maps(), and root().
Referenced by precompute_x_coordinates_for_tree().
Preorder traversal of a tree.
tree_preorder_traversal((root,visit) performs a preorder traversal over the tree rooted at root. If visitFct is specified, then for each visited node the function is invoked.
The visit function has the following specification:
void (visitFct)(Node p, int level, int pos)
Where:
| [in] | root | root of the tree to traverse. |
| [in] | visitFct | pointer to the visit function. |
| domain_error | if root is not a root node of a tree. |
Definition at line 835 of file tpl_tree_node.H.
References Aleph::__tree_preorder_traversal(), ah_domain_error_if, Aleph::maps(), and root().
Referenced by compute_coordinates_for_forest_and_set_picture_size(), and compute_coordinates_for_tree().
Compute a bit code for the binary tree.
tree_to_bits(root) takes the binary tree with root and computes its prefix code (Lukasiewicz`s word) in a bit array
| [in] | root | the root |
| bad_alloc | if there is no enough memory |
Definition at line 1051 of file tpl_binNodeUtils.H.
References Aleph::maps(), root(), and Aleph::tree_to_bits().
Compute a bit code for the binary tree.
tree_to_bits(root, array) takes the binary tree with root and computes its prefix code (Lukasiewiczs word) in a bitarray`.
| [in] | root | the root |
| [out] | array | bit array where the code will be stored |
| bad_alloc | if there is no enough memory |
Definition at line 1023 of file tpl_binNodeUtils.H.
References Aleph::LLINK(), Aleph::BitArray::push(), Aleph::RLINK(), root(), and Aleph::tree_to_bits().
Referenced by Aleph::code(), Aleph::save_tree(), Aleph::Huffman_Encoder_Engine::save_tree(), Aleph::save_tree_in_array_of_chars(), TEST(), TEST(), TEST(), TEST(), Aleph::tree_to_bits(), and Aleph::tree_to_bits().