本文整理汇总了C++中LList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::size方法的具体用法?C++ LList::size怎么用?C++ LList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
LList<int> llist;
LList<int>::iterator it = llist.begin();
LList<int>::iterator it2 = llist.end();
it2 = LList<int>::iterator(it);
#if 1
it = llist.insert(it,1);
it = llist.insert(it,2);
it = llist.insert(it,3);
it = llist.begin();
cout<<"--------insert-------------"<<endl;
for(;it != llist.end();it++)
cout<<*it<<endl;
llist.clear();
llist.push_back(11);
llist.push_back(12);
llist.push_back(13);
llist.erase(llist.begin());
cout<<"--------push_back-------------"<<endl;
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
llist.clear();
cout<<"--------size-------------"<<llist.size()<<endl;
llist.push_back(14);
llist.push_back(15);
llist.push_back(16);
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
cout<<"--------transfer-------------"<<llist.size()<<endl;
LList<int>::iterator first= ++llist.begin();
LList<int>::iterator last= llist.end();
llist.transfer(++llist.begin(),++first,last);
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
cout<<"--------reverse-------------"<<llist.size()<<endl;
llist.reverse();
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
#endif
return 0;
}
示例2: main
int main() {
LList<Pokemon> pokedex;
pokedex.push_back(Pokemon(1, "Bulbasaur"));
pokedex.push_back(Pokemon(4, "Charmander"));
pokedex.push_back(Pokemon(7, "Squirtle"));
for (int i = 0; i < pokedex.size(); i++) {
std::cout << pokedex.get(i).name << std::endl;
}
return 0;
}
示例3: Oplus
void LList::Oplus(LList& L1)
{
int i,j,k,pos;
int AddDim = L1.size();
int OldDim = dim;
int OldClassSize=0;
if (OldDim!=0) OldClassSize = data[0].Gname.size();
LevelArray OldBody;
Level TmpLevel;
if (OldDim != 0)
{
OldBody.assign(OldDim+1,TmpLevel);
for (i=0;i<=OldDim;i++)
{
OldBody[i].Gname.assign(OldClassSize,1);
for (j=0;j<OldClassSize;j++)
OldBody[i].Gname[j] = data[i].Gname[j];
OldBody[i].Gnr = data[i].Gnr;
}
}
dim = (AddDim+1)*(OldDim+1) - 1;
data.assign(dim+1,TmpLevel);
pos=0;
for (i=0;i<=OldDim;i++)
{
for (j=0;j<=AddDim;j++)
{
data[pos].Gname.assign(OldClassSize+1,1);
if (OldDim!=0) for (k=0;k<OldClassSize;k++) data[pos].Gname[k] = OldBody[i].Gname[k];
data[pos].Gname[OldClassSize] = L1[j]->Gname[0];
if (OldDim!=0)
data[pos].Gnr = OldBody[i].Gnr + L1[j]->Gnr;
else
data[pos].Gnr = L1[j]->Gnr;
pos++;
}
}
OldBody.erase(OldBody.begin(),OldBody.end());
}
示例4: ParseMemoryLeakFile
void ParseMemoryLeakFile(const char *_inputFilename, const char *_outputFilename)
{
/* */
/* Start up */
/* */
RedBlackTree<char *, int> combined;
RedBlackTree<char *, int> frequency;
int unrecognised = 0;
/* */
/* Open the file and start parsing */
/* */
FILE *memoryfile = fopen(_inputFilename, "rb");
while (memoryfile && !feof(memoryfile)) {
char thisline[1024];
fgets(thisline, 1024, memoryfile);
if (!strncmp(thisline, " Data:", 6) == 0) { /* This line is a data line - useless to us */
if (strchr(thisline, ':')) { /* This line does not have a source file location - useless to us */
/* Get the size */
char *lastcomma = strrchr(thisline, ',');
if (lastcomma == 0) continue;
char *ssize = lastcomma + 2;
int size;
char unused[32];
sscanf(ssize, "%d %s", &size, unused);
/* Get the source file name */
char *sourcelocation = thisline;
char *colon = strrchr(thisline, ':');
*(colon - 1) = '\x0';
/* Put the result into our BTree */
int result = 0;
bool found = combined.find(sourcelocation, result);
if (found)
combined.replace(sourcelocation, result + size);
else
combined.insert(sourcelocation, size);
found = frequency.find(sourcelocation, result);
if (frequency.exists(sourcelocation))
frequency.replace(sourcelocation, result + size);
else
frequency.insert(sourcelocation, 1);
} else {
char *lastcomma = strrchr(thisline, ',');
if (lastcomma) {
char *ssize = lastcomma + 2;
int size;
char unused[32];
sscanf(ssize, "%d %s", &size, unused);
unrecognised += size;
}
}
}
}
fclose(memoryfile);
/* */
/* Sort the results into a list */
/* */
LList<char *> sorted;
DArray<char *> *dataI = combined.ConvertIndexToDArray();
DArray<int> *dataD = combined.ConvertToDArray();
int totalsize = 0;
for (size_t i = 0; i < dataI->size(); i++) {
if (dataI->valid(i)) {
char *newsource = dataI->get(i);
int newsize = dataD->get(i);
totalsize += newsize;
bool inserted = false;
for (size_t i = 0; i < sorted.size(); i++) {
char *existingsource = sorted.get(i);
int existingsize;
combined.find(existingsource, existingsize);
//.........这里部分代码省略.........