本文整理汇总了C++中LList::numItems方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::numItems方法的具体用法?C++ LList::numItems怎么用?C++ LList::numItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::numItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteBranchList
void WriteBranchList ( LList<BranchPtr> &blist, IntegerSink &isink )
{
unsigned long n = blist.numItems();
isink.writeDec ( n ); // number of branches in node
for ( unsigned i=0; i < n; i++ )
{
blist[i]->write ( isink );
}
}
示例2: querySize
unsigned long Branch::querySize() const
{
unsigned long size = 3; // up front overhead: size + move + reply count
for ( unsigned i=0; i < replies.numItems(); i++ )
{
BranchPtr r = replies[i];
size += r->querySize(); // count + branchlist size
}
return size;
}
示例3: ReadData
void ReadData ( const char *inFilename,
FILE *infile,
LList<BranchPtr> &library )
{
printf ( "Reading from file '%s'\n", inFilename );
char line [128];
LList<BranchPtr> *current = 0;
while ( fgets ( line, sizeof(line), infile ) )
{
if ( StripComments ( line ) )
{
if ( line[0] == '[' )
{
// We have found the start of a new opening continuation
current = &library;
printf ( "processing %s\n", line );
}
else
{
// We have found the next move in the current continuation
if ( !current )
{
fprintf ( stderr,
"Error: move '%s' is not in a continuation!\n",
line );
exit(1);
}
int len = (int) strlen(line);
int isValid = 0;
if ( len == 4 || (len == 5 && line[4] == '?') )
{
int x1 = line[0] - 'a';
int y1 = line[1] - '1';
int x2 = line[2] - 'a';
int y2 = line[3] - '1';
if ( x1 >= 0 && x1 <= 7 &&
y1 >= 0 && y1 <= 7 &&
x2 >= 0 && x2 <= 7 &&
y2 >= 0 && y2 <= 7 )
{
isValid = 1;
unsigned short source = (x1+2) + (y1+2)*12;
unsigned short dest = (x2+2) + (y2+2)*12;
unsigned short move = (source << 8) | dest;
// First, see if this move is already there...
Branch *b = 0;
for ( unsigned j=0; j < current->numItems(); j++ )
{
Branch *x = (*current)[j];
if ( x->move == move )
{
b = x;
break;
}
}
if ( !b )
{
// This branch wasn't found, so create it!
b = new Branch;
if ( !b )
{
fprintf ( stderr, "Error: out of memory!\n" );
exit(1);
}
b->isBad = (line[4] == '?');
b->move = move;
if ( current->addToBack ( b ) != DDC_SUCCESS )
{
fprintf ( stderr, "Error adding branch to node!\n" );
exit(1);
}
}
current = &(b->replies);
}
}
if ( !isValid )
{
fprintf ( stderr,
"Error: invalid move syntax: '%s'\n",
line );
exit(1);
}
}
}
//.........这里部分代码省略.........