本文整理汇总了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();
}
示例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;
}
}
示例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;
}