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


C++ valuemap::Range类代码示例

本文整理汇总了C++中valuemap::Range的典型用法代码示例。如果您正苦于以下问题:C++ Range类的具体用法?C++ Range怎么用?C++ Range使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Range类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MarkKey

void
MapObject::mark(JSTracer* trc, JSObject* obj)
{
    if (ValueMap* map = obj->as<MapObject>().getData()) {
        for (ValueMap::Range r = map->all(); !r.empty(); r.popFront()) {
            MarkKey(r, r.front().key, trc);
            TraceEdge(trc, &r.front().value, "value");
        }
    }
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:10,代码来源:MapObject.cpp

示例2: MapIteratorObjectRange

bool
MapIteratorObject::next(JSContext* cx, Handle<MapIteratorObject*> mapIterator,
                        HandleArrayObject resultPairObj)
{
    MOZ_ASSERT(resultPairObj->getDenseInitializedLength() == 2);

    ValueMap::Range* range = MapIteratorObjectRange(mapIterator);
    if (!range || range->empty()) {
        js_delete(range);
        mapIterator->setReservedSlot(RangeSlot, PrivateValue(nullptr));
        return true;
    }
    switch (mapIterator->kind()) {
      case MapObject::Keys:
        resultPairObj->setDenseElementWithType(cx, 0, range->front().key.get());
        break;

      case MapObject::Values:
        resultPairObj->setDenseElementWithType(cx, 1, range->front().value);
        break;

      case MapObject::Entries: {
        resultPairObj->setDenseElementWithType(cx, 0, range->front().key.get());
        resultPairObj->setDenseElementWithType(cx, 1, range->front().value);
        break;
      }
    }
    range->popFront();
    return false;
}
开发者ID:paulmadore,项目名称:luckyde,代码行数:30,代码来源:MapObject.cpp

示例3:

bool
MapObject::getKeysAndValuesInterleaved(JSContext* cx, HandleObject obj,
                                       JS::MutableHandle<GCVector<JS::Value>> entries)
{
    ValueMap* map = obj->as<MapObject>().getData();
    if (!map)
        return false;

    for (ValueMap::Range r = map->all(); !r.empty(); r.popFront()) {
        if (!entries.append(r.front().key.get()) ||
            !entries.append(r.front().value))
        {
            return false;
        }
    }

    return true;
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:18,代码来源:MapObject.cpp

示例4: MapIteratorObjectRange

bool
MapIteratorObject::next(JSContext* cx, Handle<MapIteratorObject*> mapIterator,
                        HandleArrayObject resultPairObj)
{
    // Check invariants for inlined _GetNextMapEntryForIterator.

    // The array should be tenured, so that post-barrier can be done simply.
    MOZ_ASSERT(resultPairObj->isTenured());

    // The array elements should be fixed.
    MOZ_ASSERT(resultPairObj->hasFixedElements());
    MOZ_ASSERT(resultPairObj->getDenseInitializedLength() == 2);
    MOZ_ASSERT(resultPairObj->getDenseCapacity() >= 2);

    ValueMap::Range* range = MapIteratorObjectRange(mapIterator);
    if (!range || range->empty()) {
        js_delete(range);
        mapIterator->setReservedSlot(RangeSlot, PrivateValue(nullptr));
        return true;
    }
    switch (mapIterator->kind()) {
      case MapObject::Keys:
        resultPairObj->setDenseElementWithType(cx, 0, range->front().key.get());
        break;

      case MapObject::Values:
        resultPairObj->setDenseElementWithType(cx, 1, range->front().value);
        break;

      case MapObject::Entries: {
        resultPairObj->setDenseElementWithType(cx, 0, range->front().key.get());
        resultPairObj->setDenseElementWithType(cx, 1, range->front().value);
        break;
      }
    }
    range->popFront();
    return false;
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:38,代码来源:MapObject.cpp


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