本文整理汇总了C++中LList::insert_at方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::insert_at方法的具体用法?C++ LList::insert_at怎么用?C++ LList::insert_at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::insert_at方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseMemoryLeakFile
//.........这里部分代码省略.........
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);
if (newsize <= existingsize) {
sorted.insert_at(newsource, i);
inserted = true;
break;
}
}
if (!inserted)
sorted.insert(newsource);
}
}
delete dataI;
delete dataD;
/* */
/* Open the output file */
/* */
if (sorted.size()) {
FILE *output = fopen(_outputFilename, "wt");
/* */
/* Print out our sorted list */
/* */
fprintf(output, "Total recognised memory leaks : %d Kbytes\n",
int( totalsize / 1024 ));
fprintf(output, "Total unrecognised memory leaks : %d Kbytes\n\n",
int( unrecognised / 1024 ));
for (int k = (int)sorted.size() - 1; k >= 0 && k < (int)sorted.size(); k--) {
char *source = sorted.get(k);
CoreAssert(source);
int size; combined.find(source, size);
int freq; frequency.find(source, freq);
if (size > 1048576) {
fprintf(output, "%-95s (%d MB in %d leaks)\n", source,
int( size / 1048576 ), freq);
} else if (size > 2048) {
fprintf(output, "%-95s (%d KB in %d leaks)\n", source,
int( size / 1024 ), freq);
} else {
fprintf(output, "%-95s (%d bytes in %d leaks)\n", source, size,
freq);
}
}
/* */
/* Clean up */
fclose(output);
}
}