本文整理汇总了C++中ClassList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ ClassList::count方法的具体用法?C++ ClassList::count怎么用?C++ ClassList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassList
的用法示例。
在下文中一共展示了ClassList::count方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createAreaPages_getExternalConnections
void WikiAreaPages::createAreaPages_getExternalConnections( MindArea *area , MindLocalCircuitDef& circuit , MapStringToClass<MindLocalCircuitConnectionDef>& connections , bool isin ) {
ClassList<MindLocalCircuitConnectionDef> links;
circuit.getExternalConnections( links , isin );
MindService *ms = MindService::getService();
for( int k = 0; k < links.count(); k++ ) {
MindLocalCircuitConnectionDef *c = links.get( k );
// ignore secondary
if( !c -> isPrimary() )
continue;
String key;
if( isin == false ) {
MindRegion *region = ms -> getMindRegion( c -> getDstRegion() );
key = region -> getArea() -> getAreaId() + "#" + c -> getSrcRegion() + "#" + c -> getDstRegion() + "#1";
if( connections.get( key ) == NULL )
connections.add( key , c );
}
else {
MindRegion *region = ms -> getMindRegion( c -> getSrcRegion() );
key = region -> getArea() -> getAreaId() + "#" + c -> getDstRegion() + "#" + c -> getSrcRegion() + "#2";
if( connections.get( key ) == NULL )
connections.add( key , c );
}
}
}
示例2: output_nerve
void NerveTool::output_nerve( FILE *sout , ClassList<Nerve>& nn , int k ) {
Nerve& n = nn.getRef( k );
bool hasChilds = false;
int upLevelCount = 0;
if( nn.count() > ( k + 1 ) ) {
Nerve& nx = nn.getRef( k + 1 );
if( nx.level > n.level )
hasChilds = true;
else
upLevelCount = n.level - nx.level;
}
else
upLevelCount = n.level;
String tabs = String( "\t" ).replicate( 2 + n.level );
String s = tabs + "<element name=\"" + n.name + "\"";
if( !n.synonyms.isEmpty() )
s += "\n" + tabs + "\tsynonyms=\"" + n.synonyms + "\"";
if( !n.origin.isEmpty() )
s += "\n" + tabs + "\torigin=\"" + n.origin + "\"";
if( !n.distribution.isEmpty() )
s += "\n" + tabs + "\tdistribution=\"" + n.distribution + "\"";
if( !n.imginfo.isEmpty() )
s += "\n" + tabs + "\t" + n.imginfo;
if( !n.modality.isEmpty() )
s += "\n" + tabs + "\tmodality=\"" + n.modality + "\"";
if( n.fibers.isEmpty() ) {
if( hasChilds )
s +="\n" + tabs + "\t>\n";
else
s +="\n" + tabs + "\t/>\n";
}
else {
s += "\n" + tabs + "\t>";
String fibersinfo;
for( int z = 0; z < n.fibersinfo.count(); z++ )
fibersinfo += tabs + "\t" + n.fibersinfo.get( z ) + "\n";
s += "\n" + fibersinfo;
if( !hasChilds )
s += tabs + "</element>\n";
}
for( int z = 1; z <= upLevelCount; z++ ) {
tabs = String( "\t" ).replicate( 2 + n.level - z );
s += tabs + "</element>\n";
}
if( ( n.level == 0 && hasChilds == false ) || ( n.level > 0 && ( n.level - upLevelCount ) == 0 ) )
s += "\n";
fprintf( sout , "%s" , ( const char * )s );
}
示例3: findClass
int findClass( ClassList& list, ClassLattice * node )
//---------------------------------------------------
{
for( int i = list.count(); i > 0; i -= 1 ) {
if( list[ i - 1 ] && list[ i - 1 ]->isEqual( node ) ) {
return i - 1;
}
}
return -1;
}
示例4: getNerveDivision_fibers
String WikiNerveSpecPages::getNerveDivision_fibers( ClassList<XmlNerveFiberInfo>& fibers ) {
String s;
for( int k = 0; k < fibers.count(); k++ ) {
XmlNerveFiberInfo& fiber = fibers.getRef( k );
if( k > 0 )
s += "; ";
s += fiber.type + ":" + getNerveDivision_fiberchain( fiber );
}
return( s );
}
示例5:
ThreadPoolFixedTaskListItem::ThreadPoolFixedTaskListItem( String p_name , int p_threadPoolItem , ClassList<ThreadPoolTask>& p_tasks )
: ThreadPoolItem( p_name , p_threadPoolItem ) {
currentTask = 0;
// assign task list
for( int k = 0; k < p_tasks.count(); k++ ) {
ThreadPoolTask *task = p_tasks.get( k );
task -> thread = this;
tasks.add( task );
}
}
示例6: deleteLattice
void ClassLattice::deleteLattice( void )
//--------------------------------------
{
ClassList * list;
list = _flatClasses;
for( int i = list->count(); i > 0; i -= 1 ) {
delete (*list)[ i - 1 ];
}
delete list;
}
示例7: createAreaPages_getInternalConnections
void WikiAreaPages::createAreaPages_getInternalConnections( MindArea *area , MindLocalCircuitDef& circuit , MapStringToClass<MindLocalCircuitConnectionDef>& connections ) {
ClassList<MindLocalCircuitConnectionDef> links;
circuit.getInternalConnections( links );
for( int k = 0; k < links.count(); k++ ) {
MindLocalCircuitConnectionDef *c = links.get( k );
// ignore secondary
if( !c -> isPrimary() )
continue;
String key = c -> getSrcRegion() + "#" + c -> getDstRegion();
if( connections.get( key ) == NULL )
connections.add( key , c );
}
}
示例8: create
void ThreadPool::create( ClassList<ThreadPoolTask>& tasks ) {
if( !runEnabled ) {
logger.logInfo( "ignore threadPool=" + name + ", runEnabled=false" );
return;
}
int nTasks = tasks.count();
if( nThreads > nTasks )
nThreads = nTasks;
ASSERTMSG( nThreads >= 1 , "nThreads is invalid" );
int nWhole = nTasks / nThreads;
int nPart = nTasks % nThreads;
// split objects by threads
int nFrom = 0;
for( int k = 0; k < nThreads; k++ ) {
// calculate number of objects for thread
int n = nWhole;
if( nPart ) {
n++;
nPart--;
}
// create list of thread tasks
ClassList<ThreadPoolTask> threadTasks;
threadTasks.allocate( n );
for( int j = 0; j < n; j++ ) {
ThreadPoolTask *task = tasks.get( nFrom + j );
task -> pool = this;
threadTasks.add( task );
}
// create thread (suspended) and add to the pool
String threadName = name + "#" + k;
ThreadPoolItem *thread = new ThreadPoolFixedTaskListItem( threadName , k , threadTasks );
threads.add( thread );
// configure thread
nFrom += n;
}
logger.logInfo( String( "threadpool created: name=" ) + name + ", nThreads=" + nThreads + ", nTasks=" + nTasks );
}
示例9: deserialize
void NNSamples::deserialize( Object *parent , SerializeObject& so )
{
clear();
nSizeIn = so.getPropInt( "nSizeIn" );
nSizeOut = so.getPropInt( "nSizeOut" );
ClassList<NNSample> va;
so.getPropObjectList( ( ClassList<Object>& )va , "sampleList" , true );
for( int k = 0; k < va.count(); k++ )
{
NNSample *sample = va.get( k );
data.add( sample -> getId() , sample );
}
limitType = ( LimitType )so.getPropInt( "limitType" );
maxSize = so.getPropInt( "maxSize" );
}
示例10: execute_img
int NerveTool::execute_img( String& s , FILE *sout , int level , ClassList<Nerve>& nn ) {
// extract
if( !s.startsFrom( "<img src=\"" ) )
return( 101 );
s.remove( 0 , strlen( "<img src=\"" ) );
int idx = s.find( "\"" );
if( idx < 0 )
return( 102 );
String s1 = s.getMid( 0 , idx );
s.remove( 0 , idx + 1 );
s.trim();
s.trimTrailing( '>' );
String height;
if( s.startsFrom( "height=" ) )
height = s.getMid( strlen( "height=" ) );
// create string
String img = "imgsrc=\"" + s1 + "\"";
if( !height.isEmpty() )
img += " imgheight=\"" + height + "\"";
// find nerve to add to - upper with level - 1
for( int k = nn.count() - 1; k >= 0; k-- ) {
Nerve& n = nn.getRef( k );
if( n.level < level ) {
if( !n.imginfo.isEmpty() )
return( false );
n.imginfo = img;
return( 0 );
}
}
return( 100 );
}
示例11: execute_line
int NerveTool::execute_line( String& s , FILE *sout , ClassList<Nerve>& nn ) {
if( s.startsFrom( "<img" ) )
return( execute_img( s , sout , 0 , nn ) );
// parse string
int level = s.find( "*" );
if( level < 0 )
return( 1 );
if( level < 2 )
return( 13 );
s.remove( 0 , level + 1 );
level -= 2;
if( nn.count() > 0 ) {
Nerve *np = nn.last();
if( np -> level < level )
if( level != np -> level + 1 )
return( 14 );
}
s.trim();
if( s.startsFrom( "<img" ) )
return( execute_img( s , sout , level , nn ) );
if( !s.startsFrom( "*" ) )
return( 2 );
s.remove( 0 , 1 );
// name
int idx = s.find( "*" );
if( idx < 0 )
return( 3 );
String name = s.getMid( 0 , idx );
s.remove( 0 , idx + 1 );
// synonyms
String synonyms;
if( s.startsFrom( " (" ) ) {
s.remove( 0 , 2 );
idx = s.find( ")" );
if( idx < 0 )
return( 4 );
synonyms = s.getMid( 0 , idx );
s.remove( 0 , idx + 1 );
}
String origin;
String branches;
String distribution;
String modality;
String fibers;
if( s.startsFrom( "; " ) ) {
s.remove( 0 , 2 );
if( !extract_item( sout , origin , s , "ORIGIN" ) )
return( 6 );
if( !extract_item( sout , branches , s , "BRANCHES" ) )
return( 8 );
if( !extract_item( sout , distribution , s , "DISTRIBUTION" ) )
return( 7 );
if( !extract_item( sout , modality , s , "MODALITY" ) )
return( 9 );
if( !extract_item( sout , fibers , s , "FIBERS" ) )
return( 10 );
}
if( !s.isEmpty() )
return( 11 );
Nerve *n = new Nerve;
n -> fibers = fibers;
String fibersinfo;
if( !fibers.isEmpty() )
if( !extract_fibers( sout , n -> fibersinfo , fibers ) ) {
fprintf( sout , "wrong fibers=%s\n" , ( const char * )fibers );
delete n;
return( 12 );
}
n -> name = name;
n -> synonyms = synonyms;
n -> level = level;
n -> origin = origin;
n -> branches = branches;
n -> distribution = distribution;
n -> modality = modality;
nn.add( n );
return( 0 );
}
示例12: output_data
void NerveTool::output_data( FILE *sout , ClassList<Nerve>& nn ) {
for( int k = 0; k < nn.count(); k++ )
output_nerve( sout , nn , k );
}
示例13: extract_fiberitems
bool NerveTool::extract_fiberitems( FILE *sout , StringList& fibersinfo , String type , String& value ) {
// parse value: x,y -> x,y -> x,y ...
ClassList<StringList> chain;
value.trim();
while( !value.isEmpty() ) {
String part;
int idx = value.find( "->" );
if( idx < 0 ) {
if( chain.count() == 0 )
return( false );
part = value;
value.clear();
}
else {
part = value.getMid( 0 , idx );
value.remove( 0 , idx + 2 );
value.trim();
if( value.isEmpty() )
return( false );
}
// parse part
StringList *z = new StringList;
chain.add( z );
if( !extract_codes( part , z ) ) {
fprintf( sout , "wrong part=%s\n" , ( const char * )part );
return( false );
}
// prohibit many-to-many
if( z -> count() > 1 && chain.count() > 1 ) {
StringList& zp = chain.getRef( chain.count() - 2 );
if( zp.count() > 1 )
return( false );
}
}
// chain of more than one
if( chain.count() < 2 )
return( false );
// split chain
int startChain = 0;
int startChainCount = 0;
for( int k = 0; k < chain.count(); k++ ) {
StringList& z = chain.getRef( k );
int zn = z.count();
// starter
if( k == 0 ) {
startChainCount = zn;
continue;
}
// many to one - split
if( startChainCount > 1 ) {
if( zn != 1 )
return( false );
addManyToOne( fibersinfo , type , chain.getRef( startChainCount ) , z.get( 0 ) );
startChain = k;
startChainCount = zn;
continue;
}
// allow x -> y -> z as is
if( zn == 1 ) {
if( k == chain.count() - 1 ) {
addSingleChain( fibersinfo , type , chain , startChain , k );
break;
}
continue;
}
// x -> y -> x,y - split to x -> y and y -> x,y
if( ( k - 1 ) > startChain ) {
addSingleChain( fibersinfo , type , chain , startChain , k - 1 );
startChain = k - 1;
startChainCount = 1;
}
addOneToMany( fibersinfo , type , chain.getRef( startChain ).get( 0 ) , z );
startChain = k;
startChainCount = zn;
}
chain.destroy();
return( true );
}
示例14: 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;
}