本文整理汇总了C++中BitVector::ensureSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BitVector::ensureSize方法的具体用法?C++ BitVector::ensureSize怎么用?C++ BitVector::ensureSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitVector
的用法示例。
在下文中一共展示了BitVector::ensureSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: classChangeNeedsStyleRecalc
bool Element::classChangeNeedsStyleRecalc(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses)
{
// Class vectors tend to be very short. This is faster than using a hash table.
BitVector remainingClassBits;
remainingClassBits.ensureSize(oldClasses.size());
for (unsigned i = 0; i < newClasses.size(); ++i) {
bool found = false;
for (unsigned j = 0; j < oldClasses.size(); ++j) {
if (newClasses[i] == oldClasses[j]) {
// Mark each class that is still in the newClasses so we can skip doing
// an n^2 search below when looking for removals. We can't break from
// this loop early since a class can appear more than once.
remainingClassBits.quickSet(j);
found = true;
}
}
// Class was added.
if (!found && affectedByClassSelector(newClasses[i]))
return true;
}
for (unsigned i = 0; i < oldClasses.size(); ++i) {
if (remainingClassBits.quickGet(i))
continue;
// Class was removed.
if (affectedByClassSelector(oldClasses[i]))
return true;
}
return false;
}
示例2: scheduleStyleInvalidationForClassChange
void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element& element)
{
if (!oldClasses.size())
scheduleStyleInvalidationForClassChange(newClasses, element);
// Class vectors tend to be very short. This is faster than using a hash table.
BitVector remainingClassBits;
remainingClassBits.ensureSize(oldClasses.size());
for (unsigned i = 0; i < newClasses.size(); ++i) {
bool found = false;
for (unsigned j = 0; j < oldClasses.size(); ++j) {
if (newClasses[i] == oldClasses[j]) {
// Mark each class that is still in the newClasses so we can skip doing
// an n^2 search below when looking for removals. We can't break from
// this loop early since a class can appear more than once.
remainingClassBits.quickSet(j);
found = true;
}
}
// Class was added.
if (!found)
addClassToInvalidationSet(newClasses[i], element);
}
for (unsigned i = 0; i < oldClasses.size(); ++i) {
if (remainingClassBits.quickGet(i))
continue;
// Class was removed.
addClassToInvalidationSet(oldClasses[i], element);
}
}
示例3: classChangedForElement
void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element& element)
{
ASSERT(isMaster());
InvalidationSetVector invalidationSets;
if (!oldClasses.size()) {
classChangedForElement(newClasses, element);
return;
}
// Class vectors tend to be very short. This is faster than using a hash table.
BitVector remainingClassBits;
remainingClassBits.ensureSize(oldClasses.size());
RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSet();
for (unsigned i = 0; i < newClasses.size(); ++i) {
bool found = false;
for (unsigned j = 0; j < oldClasses.size(); ++j) {
if (newClasses[i] == oldClasses[j]) {
// Mark each class that is still in the newClasses so we can skip doing
// an n^2 search below when looking for removals. We can't break from
// this loop early since a class can appear more than once.
remainingClassBits.quickSet(j);
found = true;
}
}
// Class was added.
if (!found)
ruleFeatureSet.collectInvalidationSetsForClass(invalidationSets, element, newClasses[i]);
}
for (unsigned i = 0; i < oldClasses.size(); ++i) {
if (remainingClassBits.quickGet(i))
continue;
// Class was removed.
ruleFeatureSet.collectInvalidationSetsForClass(invalidationSets, element, oldClasses[i]);
}
scheduleInvalidationSetsForElement(invalidationSets, element);
}