本文整理汇总了C++中value_type::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ value_type::reserve方法的具体用法?C++ value_type::reserve怎么用?C++ value_type::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类value_type
的用法示例。
在下文中一共展示了value_type::reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: regFind
/** Parses the input string to a vector of pairs
*
* Parses the input string in the form a,b,c{n},d{m},e,f
* to a vector of pairs with base number (a,b,c,d,e,f) and multipliers
* (1,1,n,m,e,f)
*
* \param[in] s as const std::string in the form a,b{n}
* \return std::vector<pair> with uint32_t (base, multiplier)
*/
void
parseString( const std::string s )
{
boost::regex regFind( "[0-9]+(\\{[0-9]+\\})*",
boost::regex_constants::perl );
boost::sregex_token_iterator iter( s.begin( ), s.end( ),
regFind, 0 );
boost::sregex_token_iterator end;
parsedInput.clear();
parsedInput.reserve( std::distance( iter, end ) );
for(; iter != end; ++iter )
{
std::string pM = *iter;
// find multiplier n and base b of b{n}
boost::regex regMultipl( "(.*\\{)|(\\})",
boost::regex_constants::perl );
std::string multipl = boost::regex_replace( pM, regMultipl, "" );
boost::regex regBase( "\\{.*\\}",
boost::regex_constants::perl );
std::string base = boost::regex_replace( pM, regBase, "" );
// no Multiplier {n} given
if( multipl == *iter )
multipl = "1";
const std::pair<uint32_t, uint32_t> g(
boost::lexical_cast<uint32_t > ( base ),
boost::lexical_cast<uint32_t > ( multipl ) );
parsedInput.push_back( g );
}
}
示例2: Permutation
Permutation(IterBeg beg, IterEnd end) {
oneLineNotation.reserve(std::distance(beg, end));
for (; beg != end; ++beg)
oneLineNotation.push_back(*beg);
assert(__validity_test());
}