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


C++ HostAddress::equals方法代码示例

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


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

示例1: noteHostBad

void HostCatcher::noteHostBad( HostAddress * inHost ) {
    mLock->lock();
    
    // make sure this host already exists in our list
    char exists = false;

    HostAddress *foundHost = NULL;
    
    int numHosts = mHostVector->size();

    for( int i=0; i<numHosts; i++ ) {
        HostAddress *otherHost =  *( mHostVector->getElement( i ) );

        if( otherHost->equals( inHost ) ) {
            exists = true;

            // delete the host that we've found
            mHostVector->deleteElement( i );

            foundHost = otherHost;
            
            // jump out of loop
            i = numHosts;
            }
        }

    
    if( exists ) {
        delete foundHost;
        //mHostVector->push_back( foundHost );
        }

    mLock->unlock();
    }
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:34,代码来源:HostCatcher.cpp

示例2: addHost

void HostCatcher::addHost( HostAddress * inHost ) {
    

    // convert to numerical form once and for all here
    // (to avoid converting over and over in equals checks below)
    HostAddress *numericalAddress = inHost->getNumericalAddress();

    if( numericalAddress != NULL ) {

        mLock->lock();
        
        // make sure this host doesn't already exist in our list
        char exists = false;
    
        int numHosts = mHostVector->size();
    
        for( int i=0; i<numHosts; i++ ) {
            HostAddress *otherHost =  *( mHostVector->getElement( i ) );

            if( otherHost->equals( numericalAddress ) ) {
                exists = true;
                // jump out of loop
                i = numHosts;
                }
            }
    
    
    
        if( !exists ) {
            mHostVector->push_back( numericalAddress->copy() );
            }
        
    
        while( mHostVector->size() > mMaxListSize ) {
            // remove first host from queue
            HostAddress *host = *( mHostVector->getElement( 0 ) );
            mHostVector->deleteElement( 0 );
            delete host;
            }
    
        mLock->unlock();

        delete numericalAddress;
        }
    }
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:45,代码来源:HostCatcher.cpp

示例3: HostAddress

SimpleVector<HostAddress *> *HostCatcher::getHostList(
    int inMaxHostCount,
    HostAddress *inSkipHost ) {

    HostAddress *hostToSkip;

    if( inSkipHost != NULL ) {
        hostToSkip = inSkipHost->copy();
        }
    else {
        // don't skip any host
        // create a dummy host that won't match any other valid hosts
        // make sure dummy is in numerical form to avoid DNS lookups
        hostToSkip = new HostAddress( stringDuplicate( "1.1.1.1" ), 1 );
        }
             
    
    SimpleVector<HostAddress *> *collectedHosts =
        new SimpleVector<HostAddress *>();

    char repeat = false;
    int numCollected = 0;

    // This function assumes that getHostOrdered() draws
    // hosts in order with no repetition except when we have
    // exhausted the host supply.

    // Note that this will not be true when other threads
    // have getHostOrdered() (or getHost) calls interleaved with ours, but this
    // should be a rare case.  It will simply result
    // in a smaller host list being returned.

    HostAddress *firstHost = getHostOrdered();

    if( firstHost == NULL ) {
        // the catcher is empty

        delete hostToSkip;

        // an empty host list
        return collectedHosts;       
        }
    

    if( ! hostToSkip->equals( firstHost ) ) {
        collectedHosts->push_back( firstHost );
        numCollected++;
        }

    
    while( numCollected < inMaxHostCount && !repeat ) {

        HostAddress *nextHost = getHostOrdered();

        if( nextHost->equals( firstHost ) ) {
            delete nextHost;
            repeat = true;
            }
        else {
            if( ! hostToSkip->equals( nextHost ) ) {
                collectedHosts->push_back( nextHost );
                numCollected++;
                }
            else {
                delete nextHost;
                }
            }
        
        }


    if( hostToSkip->equals( firstHost ) ) {
        // we didn't include firstHost in our collectedHosts, so
        // we must delete it.
        delete firstHost;
        }

    
    delete hostToSkip;

    return collectedHosts;
    }
开发者ID:MrPhil,项目名称:CastleDoctrine,代码行数:82,代码来源:HostCatcher.cpp


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