本文整理汇总了C++中valuemap::Range::front方法的典型用法代码示例。如果您正苦于以下问题:C++ Range::front方法的具体用法?C++ Range::front怎么用?C++ Range::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类valuemap::Range
的用法示例。
在下文中一共展示了Range::front方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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");
}
}
}
示例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;
}
示例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;
}