本文整理汇总了C++中StringVector::ensureCapacity方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVector::ensureCapacity方法的具体用法?C++ StringVector::ensureCapacity怎么用?C++ StringVector::ensureCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVector
的用法示例。
在下文中一共展示了StringVector::ensureCapacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
ConfigScope::listLocalNames(
Configuration::Type typeMask,
StringVector & vec) const
{
int i;
int countWanted;
int countUnwanted;
ConfigScopeEntry * entry;
//--------
// Iterate over all the entries in the hash table and copy
// their names into the StringVector
//--------
vec.empty();
vec.ensureCapacity(m_numEntries);
countWanted = 0;
countUnwanted = 0;
for (i = 0; i < m_tableSize; i++) {
entry = m_table[i].m_next;
while (entry) {
if (entry->type() & typeMask) {
vec.add(entry->name());
countWanted++;
} else {
countUnwanted++;
}
entry = entry->m_next;
}
}
assert(countWanted + countUnwanted == m_numEntries);
}
示例2: listFilter
void
ConfigScope::listScopedNamesHelper(
const char * prefix,
Configuration::Type typeMask,
bool recursive,
const StringVector & filterPatterns,
StringVector & vec) const
{
int i;
ConfigScopeEntry * entry;
StringBuffer scopedName;
//--------
// Iterate over all the entries in the hash table and copy
// their locally-scoped names into the StringVector
//--------
vec.ensureCapacity(vec.length() + m_numEntries);
for (i = 0; i < m_tableSize; i++) {
entry = m_table[i].m_next;
while (entry) {
scopedName = prefix;
if (prefix[0] != '\0') {
scopedName.append(".");
}
scopedName.append(entry->name());
if ((entry->type() & typeMask)
&& listFilter(scopedName.c_str(), filterPatterns))
{
vec.add(scopedName);
}
if (recursive && entry->type() == Configuration::CFG_SCOPE) {
entry->item()->scopeVal()->listScopedNamesHelper(
scopedName.c_str(), typeMask,
true, filterPatterns, vec);
}
entry = entry->m_next;
}
}
}