当前位置: 首页>>代码示例>>C++>>正文


C++ ClassList::replaceAt方法代码示例

本文整理汇总了C++中ClassList::replaceAt方法的典型用法代码示例。如果您正苦于以下问题:C++ ClassList::replaceAt方法的具体用法?C++ ClassList::replaceAt怎么用?C++ ClassList::replaceAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ClassList的用法示例。


在下文中一共展示了ClassList::replaceAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: joinLattice

void ClassLattice::joinLattice( ClassLattice * lattTo )
//-----------------------------------------------------
{
    ClassList* list = _flatClasses;
    ClassList  adjust;
    int        levelDiff = 0;
    bool       levelSet = FALSE;
    int        i;

    REQUIRE( lattTo != this, "classlattice::joinlattice -- join to myself" );

    for( i = 0; i < list->count(); i += 1 ) {
        ClassLattice * node = (*list)[ i ];
        if( node != NULL ) {
            adjust.add( node );

            for( int j = node->_bases.count(); j > 0; j -= 1 ) {
                DerivationPtr * basePtr = node->_bases[ j - 1 ];
                REQUIRE( node->_flatClasses != lattTo->_flatClasses,
                         "ClassLattice::JoinLattice tried to join related" );
                int index = findClass( *lattTo->_flatClasses, basePtr->_class );

                if( index >= 0 ) {
                    //NYI rely on not having loaded deriveds (otherwise, might kill me!)
                    REQUIRE( !basePtr->_class->_derivedsLoaded, "joinLattice ack" );

                    list->replaceAt( findClass( *list, basePtr->_class ), NULL );

                    if( basePtr->_class != (*lattTo->_flatClasses)[ index ] ) {
                        delete basePtr->_class;


                        // this should probably be a separate function
                        // what it is doing is changing all of the pointers
                        // from basePtr->_class to the same class in lattTo

                        for( int k = list->count(); k > 0; k -= 1 ) {
                            ClassLattice * work = (*list)[ k - 1 ];
                            if( work != NULL ) {
                                for( int l = work->_bases.count(); l > 0; l -= 1 ) {
                                    if( work->_bases[ l - 1 ]->_class == basePtr->_class ) {
                                        work->_bases[ l - 1 ]->adjustTo( (*lattTo->_flatClasses)[ index ] );

                                        int tryDiff = work->_bases[ l - 1 ]->_class->_level + 1 - work->_level;
                                        if( !levelSet ) {
                                            levelDiff = tryDiff;
                                            levelSet = TRUE;
                                        } else {
                                            if( tryDiff > levelDiff ) {
                                                levelDiff = tryDiff;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            node->_flatClasses = lattTo->_flatClasses;
            lattTo->_flatClasses->add( node );
        }
    }

    for( i = adjust.count(); i > 0; i -= 1 ) {
        adjust[ i - 1 ]->_level += levelDiff;
    }
    delete list;
}
开发者ID:Ukusbobra,项目名称:open-watcom-v2,代码行数:69,代码来源:classlat.cpp


注:本文中的ClassList::replaceAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。