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


C++ value_type::reserve方法代码示例

本文整理汇总了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 );
        }
    }
开发者ID:AK9527lq,项目名称:picongpu,代码行数:44,代码来源:ParserGridDistribution.hpp

示例2: Permutation

 Permutation(IterBeg beg, IterEnd end) {
     oneLineNotation.reserve(std::distance(beg, end));
     for (; beg != end; ++beg)
         oneLineNotation.push_back(*beg);
     assert(__validity_test());
 }
开发者ID:Mizuchi,项目名称:SBL,代码行数:6,代码来源:permutation.hpp


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