亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? avltree.cpp

?? The existed tree implementation
?? CPP
字號:
    #include "AvlTree.h"    #include <iostream.h>    /**     * Implements an unbalanced Avl search tree.     * Note that all "matching" is based on the compares method.     * @author Mark Allen Weiss     */        /**         * Construct the tree.         */        template <class Comparable>        AvlTree<Comparable>::AvlTree( const Comparable & notFound ) :          ITEM_NOT_FOUND( notFound ), root( NULL )        {        }        /**         * Copy constructor.         */        template <class Comparable>        AvlTree<Comparable>::AvlTree( const AvlTree<Comparable> & rhs ) :          ITEM_NOT_FOUND( rhs.ITEM_NOT_FOUND ), root( NULL )        {           *this = rhs;        }        /**         * Destructor for the tree.         */        template <class Comparable>        AvlTree<Comparable>::~AvlTree( )        {            makeEmpty( );        }        /**         * Insert x into the tree; duplicates are ignored.         */        template <class Comparable>        void AvlTree<Comparable>::insert( const Comparable & x )        {            insert( x, root );        }        /**         * Remove x from the tree. Nothing is done if x is not found.         */        template <class Comparable>        void AvlTree<Comparable>::remove( const Comparable & x )        {            cout << "Sorry, remove unimplemented; " << x <<                 " still present" << endl;        }        /**         * Find the smallest item in the tree.         * Return smallest item or ITEM_NOT_FOUND if empty.         */        template <class Comparable>        const Comparable & AvlTree<Comparable>::findMin( ) const        {            return elementAt( findMin( root ) );        }        /**         * Find the largest item in the tree.         * Return the largest item of ITEM_NOT_FOUND if empty.         */        template <class Comparable>        const Comparable & AvlTree<Comparable>::findMax( ) const        {            return elementAt( findMax( root ) );        }        /**         * Find item x in the tree.         * Return the matching item or ITEM_NOT_FOUND if not found.         */        template <class Comparable>        const Comparable & AvlTree<Comparable>::                                 find( const Comparable & x ) const        {            return elementAt( find( x, root ) );        }        /**         * Make the tree logically empty.         */        template <class Comparable>        void AvlTree<Comparable>::makeEmpty( )        {            makeEmpty( root );        }        /**         * Test if the tree is logically empty.         * Return true if empty, false otherwise.         */        template <class Comparable>        bool AvlTree<Comparable>::isEmpty( ) const        {            return root == NULL;        }        /**         * Print the tree contents in sorted order.         */        template <class Comparable>        void AvlTree<Comparable>::printTree( ) const        {            if( isEmpty( ) )                cout << "Empty tree" << endl;            else                printTree( root );        }        /**         * Deep copy.         */        template <class Comparable>        const AvlTree<Comparable> &        AvlTree<Comparable>::        operator=( const AvlTree<Comparable> & rhs )        {            if( this != &rhs )            {                makeEmpty( );                root = clone( rhs.root );            }            return *this;        }        /**         * Internal method to get element field in node t.         * Return the element field or ITEM_NOT_FOUND if t is NULL.         */        template <class Comparable>        const Comparable & AvlTree<Comparable>::elementAt( AvlNode<Comparable> *t ) const        {            if( t == NULL )               return ITEM_NOT_FOUND;            else               return t->element;        }        /**         * Internal method to insert into a subtree.         * x is the item to insert.         * t is the node that roots the tree.         */        template <class Comparable>        void AvlTree<Comparable>::insert( const Comparable & x, AvlNode<Comparable> * & t ) const        {            if( t == NULL )                t = new AvlNode<Comparable>( x, NULL, NULL );            else if( x < t->element )            {                insert( x, t->left );                if( height( t->left ) - height( t->right ) == 2 )                    if( x < t->left->element )                        rotateWithLeftChild( t );                    else                        doubleWithLeftChild( t );            }            else if( t->element < x )            {                insert( x, t->right );                if( height( t->right ) - height( t->left ) == 2 )                    if( t->right->element < x )                        rotateWithRightChild( t );                    else                        doubleWithRightChild( t );            }            else                ;  // Duplicate; do nothing            t->height = max( height( t->left ), height( t->right ) ) + 1;        }        /**         * Internal method to find the smallest item in a subtree t.         * Return node containing the smallest item.         */        template <class Comparable>        AvlNode<Comparable> *        AvlTree<Comparable>::findMin( AvlNode<Comparable> *t ) const        {            if( t == NULL)                return t;            while( t->left != NULL )                t = t->left;            return t;        }        /**         * Internal method to find the largest item in a subtree t.         * Return node containing the largest item.         */        template <class Comparable>        AvlNode<Comparable> *        AvlTree<Comparable>::findMax( AvlNode<Comparable> *t ) const        {            if( t == NULL )                return t;            while( t->right != NULL )                t = t->right;            return t;        }        /**         * Internal method to find an item in a subtree.         * x is item to search for.         * t is the node that roots the tree.         * Return node containing the matched item.         */        template <class Comparable>        AvlNode<Comparable> *        AvlTree<Comparable>::find( const Comparable & x, AvlNode<Comparable> *t ) const        {            while( t != NULL )                if( x < t->element )                    t = t->left;                else if( t->element < x )                    t = t->right;                else                    return t;    // Match            return NULL;   // No match        }        /**         * Internal method to make subtree empty.         */        template <class Comparable>        void AvlTree<Comparable>::makeEmpty( AvlNode<Comparable> * & t ) const        {            if( t != NULL )            {                makeEmpty( t->left );                makeEmpty( t->right );                delete t;            }            t = NULL;        }        /**         * Internal method to clone subtree.         */        template <class Comparable>        AvlNode<Comparable> *        AvlTree<Comparable>::clone( AvlNode<Comparable> * t ) const        {            if( t == NULL )                return NULL;            else                return new AvlNode<Comparable>( t->element, clone( t->left ),                                              clone( t->right ), t->height );        }        /**         * Return the height of node t or -1 if NULL.         */        template <class Comparable>        int AvlTree<Comparable>::height( AvlNode<Comparable> *t ) const        {            return t == NULL ? -1 : t->height;        }        /**         * Return maximum of lhs and rhs.         */        template <class Comparable>        int AvlTree<Comparable>::max( int lhs, int rhs ) const        {            return lhs > rhs ? lhs : rhs;        }        /**         * Rotate binary tree node with left child.         * For AVL trees, this is a single rotation for case 1.         * Update heights, then set new root.         */        template <class Comparable>        void AvlTree<Comparable>::rotateWithLeftChild( AvlNode<Comparable> * & k2 ) const        {            AvlNode<Comparable> *k1 = k2->left;            k2->left = k1->right;            k1->right = k2;            k2->height = max( height( k2->left ), height( k2->right ) ) + 1;            k1->height = max( height( k1->left ), k2->height ) + 1;            k2 = k1;        }        /**         * Rotate binary tree node with right child.         * For AVL trees, this is a single rotation for case 4.         * Update heights, then set new root.         */        template <class Comparable>        void AvlTree<Comparable>::rotateWithRightChild( AvlNode<Comparable> * & k1 ) const        {            AvlNode<Comparable> *k2 = k1->right;            k1->right = k2->left;            k2->left = k1;            k1->height = max( height( k1->left ), height( k1->right ) ) + 1;            k2->height = max( height( k2->right ), k1->height ) + 1;            k1 = k2;        }        /**         * Double rotate binary tree node: first left child.         * with its right child; then node k3 with new left child.         * For AVL trees, this is a double rotation for case 2.         * Update heights, then set new root.         */        template <class Comparable>        void AvlTree<Comparable>::doubleWithLeftChild( AvlNode<Comparable> * & k3 ) const        {            rotateWithRightChild( k3->left );            rotateWithLeftChild( k3 );        }        /**         * Double rotate binary tree node: first right child.         * with its left child; then node k1 with new right child.         * For AVL trees, this is a double rotation for case 3.         * Update heights, then set new root.         */        template <class Comparable>        void AvlTree<Comparable>::doubleWithRightChild( AvlNode<Comparable> * & k1 ) const        {            rotateWithLeftChild( k1->right );            rotateWithRightChild( k1 );        }        /**         * Internal method to print a subtree in sorted order.         * t points to the node that roots the tree.         */        template <class Comparable>        void AvlTree<Comparable>::printTree( AvlNode<Comparable> *t ) const        {            if( t != NULL )            {                printTree( t->left );                cout << t->element << endl;                printTree( t->right );            }        }

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级日韩一级| 欧美一卡二卡三卡四卡| 精品一区二区三区在线播放| 亚洲欧洲av另类| 欧美激情综合在线| 日韩精品一区在线| 91麻豆精品国产91久久久久久久久| 91亚洲精品久久久蜜桃| 丁香婷婷综合色啪| 国产福利一区在线观看| 国产精品88888| 国产在线看一区| 国产一区二区三区四区五区美女| 秋霞电影一区二区| 精品在线播放免费| 国产乱码精品一区二区三| 国产一区二区女| 粉嫩欧美一区二区三区高清影视| 国产+成+人+亚洲欧洲自线| 国产麻豆视频一区二区| 成人精品视频.| 一本大道久久a久久综合婷婷| av亚洲产国偷v产偷v自拍| 色呦呦国产精品| 欧美一区二区三区播放老司机| 日韩欧美一级二级| 国产亚洲一区字幕| 亚洲免费观看高清完整版在线观看| 亚洲国产欧美在线人成| 亚洲不卡一区二区三区| 久久精品国产色蜜蜜麻豆| 国产精品一区在线观看你懂的| 粉嫩蜜臀av国产精品网站| 色综合色综合色综合| 亚洲视频免费在线| 麻豆精品一区二区三区| 成人短视频下载| 欧美一卡二卡三卡四卡| 亚洲欧洲国产日本综合| 看国产成人h片视频| 日本韩国一区二区三区| 久久蜜桃av一区精品变态类天堂| 亚洲精品国产无天堂网2021| 紧缚捆绑精品一区二区| 欧美性感一类影片在线播放| 国产人久久人人人人爽| 另类中文字幕网| 欧美精品自拍偷拍| 亚洲精品欧美二区三区中文字幕| 精品在线你懂的| 欧美一区二区精品久久911| 亚洲手机成人高清视频| 国产资源精品在线观看| 正在播放一区二区| 亚洲一区二区欧美| 日本高清不卡一区| 成人欧美一区二区三区小说 | 亚洲午夜国产一区99re久久| 国产99精品视频| 国产欧美一区二区精品性色| 久久国产免费看| 日韩美女视频一区二区在线观看| 亚洲欧美电影院| 色综合天天综合网国产成人综合天 | av亚洲精华国产精华精华| 亚洲国产中文字幕在线视频综合| 激情深爱一区二区| 国产欧美一区二区在线| 国产精品1区二区.| 亚洲欧美在线aaa| 在线精品亚洲一区二区不卡| 亚洲一区在线观看免费 | 亚洲欧美日韩国产综合| 色欧美日韩亚洲| 亚洲成人精品在线观看| 91精品蜜臀在线一区尤物| 午夜精品久久久久久| 日韩美一区二区三区| 国产一区二区0| 国产精品久久久久久久浪潮网站| 色激情天天射综合网| 一区二区三区四区精品在线视频| 欧美日韩你懂得| 国产成人欧美日韩在线电影| 亚洲欧洲精品一区二区精品久久久| 91电影在线观看| 精品亚洲成av人在线观看| 国产精品国产三级国产有无不卡| 欧美日韩一区中文字幕| 国产一区二区三区视频在线播放| 中文字幕制服丝袜成人av| 欧美一区二区人人喊爽| 99这里只有久久精品视频| 日本在线不卡视频一二三区| 国产精品久久久久久久蜜臀 | 欧美日韩成人在线一区| 99久久久久久| 国产自产视频一区二区三区| 亚洲一区在线免费观看| 中日韩av电影| 亚洲精品一区二区精华| 欧美亚一区二区| jlzzjlzz亚洲女人18| 国产乱码精品1区2区3区| 国产一区二区视频在线| 日本欧美一区二区| 一区二区三区国产| 国产精品传媒在线| 国产欧美日本一区视频| 欧美成人aa大片| 日韩亚洲电影在线| 91精品国产综合久久香蕉的特点| 欧美三级电影在线观看| 欧美性色黄大片| 欧美日韩一区二区在线观看视频| 欧美在线啊v一区| 色偷偷久久一区二区三区| 成人性生交大片免费看中文| 成人毛片老司机大片| jiyouzz国产精品久久| 99视频精品免费视频| 94-欧美-setu| 欧美三级在线看| 欧美一级欧美一级在线播放| 91精品国产综合久久精品app | 最新国产精品久久精品| 亚洲欧美日韩电影| 亚洲二区视频在线| 九色综合狠狠综合久久| 欧美精品日韩精品| 亚洲精品在线免费观看视频| 国产欧美日韩另类一区| 亚洲男帅同性gay1069| 五月综合激情日本mⅴ| 久久草av在线| av网站一区二区三区| 在线播放/欧美激情| www激情久久| 亚洲一区二区三区自拍| 精一区二区三区| 色天天综合久久久久综合片| 日韩美女视频在线| 亚洲综合视频在线观看| 精品一区二区久久| 91福利精品视频| 欧美国产1区2区| 免费一区二区视频| 一本一道综合狠狠老| 欧美国产欧美综合| 日本一不卡视频| 51久久夜色精品国产麻豆| 亚洲国产高清在线观看视频| 午夜精品一区在线观看| 99精品国产热久久91蜜凸| 欧美成人vps| 免费的成人av| 色av成人天堂桃色av| 国产精品久久久久精k8| 国产精品 欧美精品| 日韩美一区二区三区| 日韩精品免费专区| 欧美最猛性xxxxx直播| 亚洲视频综合在线| 色婷婷av久久久久久久| 最新久久zyz资源站| 91色综合久久久久婷婷| 欧美—级在线免费片| 粉嫩13p一区二区三区| 国产精品狼人久久影院观看方式| 蜜臀va亚洲va欧美va天堂 | 欧美一区二区不卡视频| 天堂蜜桃91精品| 欧美成人三级在线| 国模娜娜一区二区三区| 26uuu国产一区二区三区| 精品在线免费视频| 中文字幕第一区综合| hitomi一区二区三区精品| 亚洲色图在线视频| 欧美无砖砖区免费| 美女视频黄免费的久久 | 国产精品亚洲午夜一区二区三区 | 欧美日韩成人综合天天影院 | 欧美xxxx在线观看| 成人免费av在线| 亚洲人成在线播放网站岛国| 91小视频在线| 亚洲综合免费观看高清完整版 | 一本色道久久加勒比精品| 一区二区理论电影在线观看| 欧美色网一区二区| 久久99精品一区二区三区| 中文字幕一区二区三区在线不卡| av电影天堂一区二区在线观看| 亚洲欧美aⅴ...| 欧美一级日韩免费不卡| 成人一区在线看| 午夜久久久久久久久| 国产欧美日韩亚州综合| 欧美色老头old∨ideo|