当前位置: 首页>>代码示例>>C++>>正文


C++ nsTHashtable::EnumerateEntries方法代码示例

本文整理汇总了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);
  }
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:59,代码来源:TestHashtables.cpp

示例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;
  }
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:19,代码来源:nsPresArena.cpp

示例3:

static void
GetHashtableElements(nsTHashtable<nsPtrHashKey<T> >& aHashtable, nsTArray<T*>& aArray)
{
  aHashtable.EnumerateEntries(&GetHashtableEntry<T>, &aArray);
}
开发者ID:vitillo,项目名称:mozilla-central,代码行数:5,代码来源:AudioContext.cpp


注:本文中的nsTHashtable::EnumerateEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。