本文整理汇总了C++中SortedList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ SortedList::size方法的具体用法?C++ SortedList::size怎么用?C++ SortedList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedList
的用法示例。
在下文中一共展示了SortedList::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildHuffTree
void RosettaCodeProvider::buildHuffTree()
{
//build Node list from HuffCodeTable, no need to sort (already done on get call)
SortedList<HuffNode*> nodeList;
int i = 0;
HuffData* iterate = _huffCodeTable->get(i);
while(iterate != nullptr){
++i;
nodeList.addWithoutSort(new HuffNode(iterate));
iterate = _huffCodeTable->get(i);
}
//merge nodes together
while(nodeList.size() >= 2){
HuffNode* one = nodeList.remove(0);
HuffNode* two = nodeList.remove(0);
unsigned sum = one->getFrequency() + two->getFrequency();
HuffNode* three = new HuffNode(sum);
if(*one < *two){
three->_leftChild = one;
three->_rightChild = two;
}else{
three->_leftChild = two;
three->_rightChild = one;
}
nodeList.addWithSort(three);
}
if(nodeList.size() == 0){
//something went wrong
//nothing in codeTable to start with?
return;
}
if(nodeList.size() == 1){
_huffTree = new HuffTree(nodeList.remove(0));
}
}
示例2: Essai1
void Essai1()
{
cout << "----- 1. Test du template ListeTriee avec des entiers ------------------------" << endl;
cout << "Creation d'une Liste triee..." << endl;
SortedList<int> liste;
liste.display(); // --> ()
cout << endl;
cout << "On insere 3,-2,5,-1,0 et -8..." << endl;
liste.add(3);
liste.add(-2);
liste.add(5);
liste.add(-1);
liste.add(0);
liste.add(-8);
liste.display(); // --> (-8 -2 -1 0 3 5)
cout << "La liste contient " << liste.size() << " elements." << endl;
cout << endl;
}
示例3: Essai2
void Essai2()
{
cout << "----- 2. Test du template ListeTriee avec des Personnes ------------------------" << endl;
cout << "Creation d'une Liste triee..." << endl;
SortedList<Person> liste;
liste.display();
cout << endl;
cout << "On insere quelques personnes..." << endl;
liste.add(Person("Starzak","Richard"));
liste.add(Person("Vilvens","Claude"));
liste.add(Person("Mercenier","Denys"));
liste.add(Person("Wagner","Jean-Marc"));
liste.add(Person("Starzak","Luc"));
liste.add(Person("Charlet","Christophe"));
liste.add(Person("Moitroux","Cecile"));
liste.display();
cout << "La liste contient " << liste.size() << " elements." << endl;
cout << endl;
}
示例4: dumpMemoryUsage
void TextureTracker::dumpMemoryUsage(String8 &log) {
log.appendFormat("\nTextureTracker:\n");
int sum = 0;
SortedList<String8> list;
size_t count = mMemoryList.size();
for (size_t i = 0; i < count; i++) {
const String8& current = mMemoryList.itemAt(i).mName;
size_t tmp = list.size();
bool found = false;
for (size_t j = 0; j < tmp; j++) {
if (current == list.itemAt(j)) {
found = true;
break;
}
}
if (!found) {
list.add(current);
}
}
size_t tmp = list.size();
for (size_t i = 0; i < tmp; i++) {
const String8& current = list.itemAt(i);
String8 tmpString;
int tmpsum = 0;
for (size_t j = 0; j < count; j++) {
const TextureEntry& entry = mMemoryList.itemAt(j);
if (entry.mName == current) {
String8 format;
String8 type;
char s[64];
switch (entry.mFormat) {
case GL_RGBA:
format = String8("GL_RGBA");
break;
case GL_RGB:
format = String8("GL_RGB");
break;
case GL_ALPHA:
format = String8("GL_ALPHA");
break;
case GL_LUMINANCE:
format = String8("GL_LUMINANCE");
break;
case GL_LUMINANCE_ALPHA:
format = String8("GL_LUMINANCE_ALPHA");
break;
default:
sprintf(s, "0x%x", entry.mFormat);
format = String8(s);
break;
}
switch (entry.mType) {
case GL_UNSIGNED_BYTE:
type = String8("GL_UNSIGNED_BYTE");
break;
case GL_UNSIGNED_SHORT_4_4_4_4:
type = String8("GL_UNSIGNED_SHORT_4_4_4_4");
break;
case GL_UNSIGNED_SHORT_5_5_5_1:
type = String8("GL_UNSIGNED_SHORT_5_5_5_1");
break;
case GL_UNSIGNED_SHORT_5_6_5:
type = String8("GL_UNSIGNED_SHORT_5_6_5");
break;
case GL_FLOAT:
type = String8("GL_FLOAT");
break;
default:
sprintf(s, "0x%x", entry.mType);
type = String8(s);
break;
}
tmpString.appendFormat(" %d (%d, %d) (%s, %s) %d <%s> %s\n", entry.mId, entry.mWidth,
entry.mHeight, format.string(), type.string(), entry.mMemory,
entry.mPurpose.string(), entry.mGhost ? "g" : "");
tmpsum += entry.mMemory;
}
}
sum += tmpsum;
log.appendFormat("%s: %d bytes, %.2f KB, %.2f MB\n", current.string(), tmpsum, tmpsum / 1024.0f, tmpsum / 1048576.0f);
log.append(tmpString);
log.append("\n");
}
int rss = load3dUsage();
log.appendFormat("\nTotal monitored:\n %d bytes, %.2f KB, %.2f MB\n", sum, sum / 1024.0f, sum / 1048576.0f);
// log.appendFormat("Physical allocated:\n %d bytes, %.2f KB, %.2f MB\n", rss, rss / 1024.0f, rss / 1048576.0f);
// log.appendFormat("Coverage rate:\n %.2f %%\n", 100 * ((float)sum) / rss);
}