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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? btreeinn.cpp

?? uc/os 很好的學習代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
                {
                // there is no left sibling
                inner->splitWith(right, inneridx+1);
                }
            }
        else if( hasRightSib )
            {
            inner->balanceWithRight( right, inneridx+1 );
            }
        else if( leftSibFull )
            {
            left->splitWith( inner, inneridx );
            }
        else if( hasLeftSib )
            {
            inner->balanceWithLeft( left, inneridx );
            }
        else {
            CHECK(0);
            }
        }
}

void InnerNode::isLow( Node *that )
{
    // the child node THAT is <= half full.  We will either redistribute
    // elements between children, or THAT will be merged with another child.
    // In an attempt to minimize the number of mergers, we adopt the following
    // strategy:
    //  * redistribute if possible
    //  * if not possible, then merge with a sibling
    if( that->isLeaf )
        {
        LeafNode *leaf = (LeafNode *)that;
        LeafNode *left, *right;
        // split LEAF only if both sibling nodes are full.
        int leafidx = indexOf(leaf);
        int hasRightSib = (leafidx < last)
                                && ((right=(LeafNode*)getTree(leafidx+1))
                                          != 0);
        int hasLeftSib  = (leafidx > 0)
                                && ((left=(LeafNode*)getTree(leafidx-1))
                                         != 0);
        if( hasRightSib
            && (leaf->Psize() + right->Vsize()) >= leaf->maxPsize())
            {
            // then cannot merge,
            // and balancing this and rightsib will leave them both
            // more than half full
            leaf->balanceWith( right, leafidx+1 );
            }
        else if( hasLeftSib
            && (leaf->Vsize() + left->Psize()) >= leaf->maxPsize())
            {
            // ditto
            left->balanceWith( leaf, leafidx );
            }
        else if( hasLeftSib )
            {
            // then they should be merged
            left->mergeWithRight( leaf, leafidx );
            }
        else if( hasRightSib )
            {
            leaf->mergeWithRight( right, leafidx+1 );
            }
        else
            {
            CHECK(0); // should never happen
            }
        }
    else
        {
        InnerNode *inner = (InnerNode *)that;
        //
        int inneridx = indexOf(inner);
        InnerNode *left, *right;
        int hasRightSib = (inneridx < last)
                                && ((right=(InnerNode*)getTree(inneridx+1))
                                          != 0);
        int hasLeftSib  = (inneridx > 0)
                                && ((left=(InnerNode*)getTree(inneridx-1))
                                         != 0);
        if( hasRightSib
            && (inner->Psize() + right->Vsize()) >= inner->maxPsize())
            {
            // cannot merge
            inner->balanceWith( right, inneridx+1 );
            }
        else if( hasLeftSib
            && (inner->Vsize() + left->Psize()) >= inner->maxPsize())
            {
            // cannot merge
            left->balanceWith( inner, inneridx );
            }
        else if( hasLeftSib )
            {
            left->mergeWithRight( inner, inneridx );
            }
        else if( hasRightSib )
            {
            inner->mergeWithRight( right, inneridx+1 );
            }
        else
            {
            CHECK(0);
            }
        }
}

LeafNode*InnerNode::lastLeafNode()
{
    return getTree(last)->lastLeafNode();
}

void InnerNode::mergeWithRight( InnerNode* rightsib, int pidx )
{
    PRECONDITION( Psize() + rightsib->Vsize() < maxIndex() );
    if( rightsib->Psize() > 0 )
        rightsib->pushLeft( rightsib->Psize(), this, pidx );
    rightsib->setKey( 0, parent->getKey( pidx ) );
    appendFrom( rightsib, 0, 0 );
    parent->incNofKeys( pidx-1, rightsib->getNofKeys(0)+1 );
    parent->removeItem( pidx );
    delete rightsib;
}

long InnerNode::nofKeys() const
{
    long sum = 0;
    for( int i = 0; i <= last; i++)
        sum += getNofKeys(i);
    return sum + Psize();
}

Object& InnerNode::operator[]( long idx ) const
{
    for( int j=0; j <= last; j++ )
        {
        long R;
        if( idx < (R = getNofKeys(j)) )
            return (*getTree(j))[idx];
        if( idx == R )
            {
            if( j == last )
                return NOOBJECT;
            else
                return *getKey(j+1);
            }
        idx -= R+1; // +1 because of the key in the node
        }
    return NOOBJECT;
}

void InnerNode::printOn(ostream& out) const
{
    out << " [ " << "/" << getNofKeys(0) << *getTree(0);
    for( int i = 1; i <= last; i++ )
        {
        //*!*!*!*!* not for distribution!
        CHECK( getTree(i)->debugKey == 1017 );
        if( i > 1 )
            CHECK( *getKey(i-1) <= *getKey(i) );
        out << *getKey(i) << "/" << getNofKeys(i) << *getTree(i);
        }
    out << " ] ";
}

void InnerNode::pushLeft( int noFromThis, InnerNode* leftsib, int pidx )
{
    // noFromThis==1 => moves the parent item into the leftsib,
    // and the first item in this's array into the parent item
    PRECONDITION( parent->getTree(pidx) == this );
    PRECONDITION( noFromThis > 0 && noFromThis <= Psize() );
    PRECONDITION( noFromThis + leftsib->Psize() < maxPsize() );
    setKey( 0, parent->getKey(pidx) ); // makes appendFrom's job easier
    leftsib->appendFrom( this, 0, noFromThis-1 );
    shiftLeft( noFromThis );
    parent->setKey( pidx, getKey(0) );
    parent->setNofKeys( pidx-1, leftsib->nofKeys() );
    parent->setNofKeys( pidx, nofKeys() );
}

void InnerNode::pushRight(int noFromThis, InnerNode* rightsib, int pidx)
{
    PRECONDITION( noFromThis > 0 && noFromThis <= Psize() );
    PRECONDITION( noFromThis + rightsib->Psize() < rightsib->maxPsize() );
    PRECONDITION( parent->getTree(pidx) == rightsib );
    //
    // The operation is three steps:
    //  Step I.  Make room for the incoming keys in RIGHTSIB.
    //  Step II. Move the items from THIS into RIGHTSIB.
    //  Step III.Update the length of THIS.
    //
    // Step I.: make space for noFromThis items
    //
    int start = last - noFromThis + 1;
    int tgt, src;
    tgt = rightsib->last + noFromThis;
    src = rightsib->last;
    rightsib->last = tgt;
    rightsib->setKey( 0, parent->getKey( pidx ) ); incNofKeys(0);
    while( src >= 0 )
        {
        // do this kind of assignment on InnerNode Items only when
        // the parent fields
        // of the moved items do not change, as they don't here.
        // Otherwise, use setItem so the parents are updated appropriately.
        rightsib->getItem(tgt--) = rightsib->getItem(src--);
        }

    // Step II.Move the items from THIS into RIGHTSIB
    for( int i = last; i >= start; i-- )
        {
        // this is the kind of assignment to use when parents change
        rightsib->setItem(tgt--, getItem(i));
        }
    parent->setKey( pidx, rightsib->getKey(0) );
    decNofKeys(0);
    CHECK( tgt == -1 );

    // Step III.
    last -= noFromThis;

    // Step VI.  update nofKeys
    parent->setNofKeys( pidx-1, nofKeys() );
    parent->setNofKeys( pidx, rightsib->nofKeys() );
}

void InnerNode::remove( int index )
{
    PRECONDITION( index >= 1 && index <= last );
    LeafNode* lf = getTree(index)->firstLeafNode();
    setKey( index, lf->item[0] );
    lf->removeItem(0);
}

void InnerNode::removeItem( int index )
{
    PRECONDITION( index >= 1 && index <= last );
    for( int to = index; to < last; to++ )
        item[to] = item[to+1];
    last--;
    if( isLow() )
        {
        if( parent == 0 )
            {
            // then this is the root; when only one child, make the child
            // the root
            if( Psize() == 0 )
                tree->rootIsEmpty();
            }
        else
            parent->isLow( this );
        }
}

void InnerNode::shiftLeft( int cnt )
{
    if( cnt <= 0 )
        return;
    for( int i = cnt; i <= last; i++ )
        getItem(i-cnt) = getItem(i);
    last -= cnt;
}

void InnerNode::split()
{
    // this function is called only when THIS is the only descendent
    // of the root node, and THIS needs to be split.
    // assumes that idx of THIS in Parent is 0.
    InnerNode* newnode = new InnerNode( parent );
    CHECK( newnode != 0 );
    parent->append( getKey(last), newnode );
    newnode->appendFrom( this, last, last );
    last--;
    parent->incNofKeys( 1, newnode->getNofKeys(0) );
    parent->decNofKeys( 0, newnode->getNofKeys(0) );
    balanceWithRight( newnode, 1 );
}

void
InnerNode::splitWith( InnerNode *rightsib, int keyidx )
{
    // THIS and SIB are too full; create a NEWnODE, and balance
    // the number of keys between the three of them.
    //
    // picture: (also see Knuth Vol 3 pg 478)
    //              keyidx keyidx+1
    //           +--+--+--+--+--+--...
    //           |  |  |  |  |  |
    // parent--->|  |     |     |
    //           |  |     |     |
    //           +*-+*-+*-+--+--+--...
    //            |  |  |
    //       +----+  |  +-----+
    //       |       +-----+  |
    //       V             |  V
    //       +----------+  |  +----------+
    //       |          |  |  |          |
    // this->|          |  |  |          |<--sib
    //       +----------+  |  +----------+
    //                     V
    //                    data
    //
    // keyidx is the index of where the sibling is, and where the
    // newly created node will be recorded (sibling will be moved to
    // keyidx+1)
    //
    PRECONDITION( keyidx > 0 && keyidx <= parent->last );
    // I would like to be able to prove that the following assertion
    // is ALWAYS true, but it is beyond my time limits.  If this assertion
    // ever comes up False, then the code to make it so must be inserted
    // here.
    // assert(parent->getKey(keyidx) == rightsib->getKey(0));
    // During debugging, this came up False, so
    rightsib->setKey(0,parent->getKey(keyidx));
    int nofKeys        = Psize() + rightsib->Vsize();
    int newSizeThis    = nofKeys / 3;
    int newSizeNew     = (nofKeys - newSizeThis) / 2;
    int newSizeSib     = (nofKeys - newSizeThis - newSizeNew);
    int noFromThis     = Psize() - newSizeThis;
    int noFromSib      = rightsib->Vsize() - newSizeSib;
    // because of their smaller size, this InnerNode may not have to
    // give up any elements to the new node.  I.e., noFromThis == 0.
    // This will not happen for LeafNodes.
    // We handle this by pulling an item from the rightsib.
    CHECK( noFromThis >= 0 );
    CHECK( noFromSib >= 1 );
    InnerNode* newNode = new InnerNode(parent);
    CHECK( newNode != 0 );
    if( noFromThis > 0 )
        {
        newNode->append( getItem(last) );
        parent->addElt( keyidx, getKey(last--), newNode );
        if( noFromThis > 2 )
            this->pushRight( noFromThis-1, newNode, keyidx );
        rightsib->pushLeft( noFromSib, newNode, keyidx+1 );
        }
    else
        {
        // pull an element from the rightsib
        newNode->append( rightsib->getItem(0) );
        parent->addElt( keyidx+1, rightsib->getKey(1), rightsib);
        rightsib->shiftLeft(1);
        parent->setTree( keyidx, newNode );
        rightsib->pushLeft( noFromSib-1, newNode, keyidx+1 );
        }
    parent->setNofKeys( keyidx-1, this->nofKeys() );
    parent->setNofKeys( keyidx, newNode->nofKeys() );
    parent->setNofKeys( keyidx+1, rightsib->nofKeys() );
    if( parent->isFull() )
        parent->informParent();
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区激情在线| 国内精品久久久久影院薰衣草 | 午夜a成v人精品| 亚洲欧洲www| 亚洲欧洲日韩女同| 亚洲精品一二三区| 亚洲一区二区三区国产| 又紧又大又爽精品一区二区| 天天操天天干天天综合网| 亚洲亚洲人成综合网络| 亚洲一区二区在线免费观看视频| 亚洲精品乱码久久久久久黑人 | 欧美日韩精品福利| 4438x成人网最大色成网站| 日韩一区二区在线观看视频| 欧美成人高清电影在线| 久久人人爽爽爽人久久久| 国产欧美一区二区精品仙草咪| 国产精品久久一卡二卡| 亚洲精品美腿丝袜| 久久精品久久精品| 国产成人av影院| 在线一区二区视频| 日韩一二三区不卡| 日本一区二区视频在线| 亚洲伦理在线免费看| 日本不卡视频一二三区| 国产一区二区三区观看| 99久久99久久久精品齐齐| 欧美日韩精品电影| 久久午夜色播影院免费高清| 亚洲男人的天堂av| 青青草原综合久久大伊人精品优势| 国产一区二区三区免费看| 91麻豆文化传媒在线观看| 91精品国产综合久久小美女| 国产精品拍天天在线| 午夜欧美2019年伦理| 成人av免费在线播放| 欧美日韩aaaaaa| 国产精品免费视频一区| 日本系列欧美系列| 91麻豆123| 久久精品一二三| 偷窥国产亚洲免费视频| 成人白浆超碰人人人人| 91精品国产色综合久久| 亚洲理论在线观看| 国模大尺度一区二区三区| 欧美视频在线观看一区| 一色屋精品亚洲香蕉网站| 激情综合五月天| 欧美丰满嫩嫩电影| 亚洲精品一卡二卡| 成人免费毛片app| 日韩精品一区二区三区视频播放| 亚洲午夜精品在线| 99久久精品情趣| 国产欧美视频一区二区| 麻豆成人av在线| 5566中文字幕一区二区电影| 亚洲精品欧美在线| 91亚洲精华国产精华精华液| 久久久久久久国产精品影院| 偷拍一区二区三区| 欧美人牲a欧美精品| 午夜国产不卡在线观看视频| 91国偷自产一区二区三区观看| 亚洲欧洲精品一区二区精品久久久| 人人超碰91尤物精品国产| 欧美日韩一区二区不卡| 亚洲国产wwwccc36天堂| 欧美揉bbbbb揉bbbbb| 一区二区三区 在线观看视频| 99国产麻豆精品| 国产精品二三区| 91极品视觉盛宴| 亚洲综合区在线| 欧美日韩国产首页在线观看| 午夜国产精品影院在线观看| 91精品国产综合久久精品麻豆| 亚洲精品中文字幕乱码三区| 欧美在线你懂得| 婷婷中文字幕综合| 精品福利一区二区三区免费视频| 麻豆精品在线播放| xvideos.蜜桃一区二区| 成人一级视频在线观看| 亚洲欧美另类小说| 精品污污网站免费看| 日本伊人色综合网| 国产欧美一区二区精品性色超碰| 不卡免费追剧大全电视剧网站| 亚洲欧美一区二区三区国产精品 | 亚洲色图19p| 欧美色成人综合| 久久9热精品视频| 一本大道久久精品懂色aⅴ| 国产精品1区2区3区在线观看| 国产99精品国产| 色综合久久综合网| 国产一区日韩二区欧美三区| 成人午夜碰碰视频| 天天操天天色综合| 婷婷中文字幕综合| 五月天激情综合| 午夜视频在线观看一区二区| 亚洲精品老司机| 亚洲综合成人在线| 亚洲综合免费观看高清完整版在线| 亚洲人xxxx| 亚洲摸摸操操av| 亚洲精品国产第一综合99久久| 一区精品在线播放| 中文字幕永久在线不卡| 亚洲日本在线看| 亚洲精品欧美在线| 亚洲成av人在线观看| 亚洲一区二区欧美| 天堂在线一区二区| 免费成人结看片| 国产一区二区三区免费观看| 国产精品亚洲一区二区三区在线| 国产一区二区美女诱惑| 国产一区日韩二区欧美三区| 国产福利视频一区二区三区| 国产高清久久久久| 97久久超碰精品国产| 在线观看视频欧美| 日韩一区二区电影网| 精品国产91久久久久久久妲己| 久久久久九九视频| 亚洲手机成人高清视频| 天天色天天爱天天射综合| 麻豆传媒一区二区三区| 国产91色综合久久免费分享| 成a人片亚洲日本久久| 在线观看亚洲一区| 日韩欧美国产三级| 国产精品不卡在线观看| 亚洲电影你懂得| 国产精品自拍在线| 色综合久久综合网| 欧美tk—视频vk| 中文字幕日韩精品一区| 日本视频免费一区| 成人国产精品免费观看视频| 欧美日韩一区二区在线观看| 日韩欧美一二区| 亚洲另类一区二区| 精品一区免费av| 色综合视频一区二区三区高清| 日韩天堂在线观看| 国产精品私人自拍| 日韩精品免费视频人成| 不卡av电影在线播放| 91麻豆精品国产无毒不卡在线观看| 欧美激情一区二区三区蜜桃视频 | 91精品国产aⅴ一区二区| 国产情人综合久久777777| 亚洲综合免费观看高清完整版 | 久久夜色精品国产欧美乱极品| 中文一区一区三区高中清不卡| 日韩成人伦理电影在线观看| 成人精品视频.| 日韩精品一区在线| 亚洲成人黄色小说| 91香蕉视频mp4| 中文一区二区完整视频在线观看| 日韩av网站在线观看| 色噜噜久久综合| 中文字幕乱码一区二区免费| 国产资源在线一区| 欧美日韩五月天| 亚洲午夜成aⅴ人片| 99热精品一区二区| 久久久亚洲综合| 久久99精品国产91久久来源| 欧美三片在线视频观看 | 男女性色大片免费观看一区二区| 一本大道综合伊人精品热热| 国产肉丝袜一区二区| 美腿丝袜亚洲三区| 欧美色涩在线第一页| 亚洲精选一二三| 91首页免费视频| 亚洲精品视频免费看| 99综合电影在线视频| 国产精品久久一级| 成人黄色在线视频| 中文字幕精品—区二区四季| 国产黑丝在线一区二区三区| 久久先锋资源网| 国产精品一区三区| 国产婷婷精品av在线| 国产成人在线看| 中文天堂在线一区| 一道本成人在线| 亚洲制服丝袜一区| 4438亚洲最大|