本文整理汇总了C++中nsTHashtable::EnumerateEntries方法的典型用法代码示例。如果您正苦于以下问题:C++ nsTHashtable::EnumerateEntries方法的具体用法?C++ nsTHashtable::EnumerateEntries怎么用?C++ nsTHashtable::EnumerateEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsTHashtable
的用法示例。
在下文中一共展示了nsTHashtable::EnumerateEntries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
void
testTHashtable(nsTHashtable<EntityToUnicodeEntry>& hash, uint32_t numEntries) {
printf("Filling hash with %d entries.\n", numEntries);
uint32_t i;
for (i = 0; i < numEntries; ++i) {
printf(" Putting entry \"%s\"...", gEntities[i].mStr);
EntityToUnicodeEntry* entry =
hash.PutEntry(gEntities[i].mStr);
if (!entry) {
printf("FAILED\n");
exit (2);
}
printf("OK...");
if (entry->mNode) {
printf("entry already exists!\n");
exit (3);
}
printf("\n");
entry->mNode = &gEntities[i];
}
printf("Testing Get:\n");
for (i = 0; i < numEntries; ++i) {
printf(" Getting entry \"%s\"...", gEntities[i].mStr);
EntityToUnicodeEntry* entry =
hash.GetEntry(gEntities[i].mStr);
if (!entry) {
printf("FAILED\n");
exit (4);
}
printf("Found %u\n", entry->mNode->mUnicode);
}
printf("Testing nonexistent entries...");
EntityToUnicodeEntry* entry =
hash.GetEntry("xxxy");
if (entry) {
printf("FOUND! BAD!\n");
exit (5);
}
printf("not found; good.\n");
printf("Enumerating:\n");
uint32_t count = hash.EnumerateEntries(nsTEnumGo, nullptr);
if (count != numEntries) {
printf(" Bad count!\n");
exit (6);
}
}
示例2: SizeOfIncludingThis
void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
nsArenaMemoryStats* aArenaStats)
{
// We do a complicated dance here because we want to measure the
// space taken up by the different kinds of objects in the arena,
// but we don't have pointers to those objects. And even if we did,
// we wouldn't be able to use aMallocSizeOf on them, since they were
// allocated out of malloc'd chunks of memory. So we compute the
// size of the arena as known by malloc and we add up the sizes of
// all the objects that we care about. Subtracting these two
// quantities gives us a catch-all "other" number, which includes
// slop in the arena itself as well as the size of objects that
// we've not measured explicitly.
size_t mallocSize = SizeOfIncludingThisFromMalloc(aMallocSizeOf);
EnumerateData data = { aArenaStats, 0 };
mFreeLists.EnumerateEntries(FreeListEnumerator, &data);
aArenaStats->mOther = mallocSize - data.total;
}
示例3:
static void
GetHashtableElements(nsTHashtable<nsPtrHashKey<T> >& aHashtable, nsTArray<T*>& aArray)
{
aHashtable.EnumerateEntries(&GetHashtableEntry<T>, &aArray);
}