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


C++ unordered_map::emplace方法代码示例

本文整理汇总了C++中boost::unordered_map::emplace方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::emplace方法的具体用法?C++ unordered_map::emplace怎么用?C++ unordered_map::emplace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::unordered_map的用法示例。


在下文中一共展示了unordered_map::emplace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: V_F

double V_F(const int& n, const int& fullObs_cumulativeTime, const int& fullObs_cumulativeQuantity)
{
    double v_max;
    
    if (n==N+1)
        v_max = 0;    //V_{N+1}()=0
    else
    {
        auto parameters = make_tuple(n, fullObs_cumulativeTime, fullObs_cumulativeQuantity);
        
        bool found = false;
        //#pragma omp critical (v_map)
        {
            auto  it = v_map.find(parameters);
            if (it != v_map.end()) {
                found = true;
                v_max = it->second;
            }
        }
        
        
        if (!found)
        {
            
            //no need to search for optimal inventory level x, the myopic inventory level is optimal
            int x_opt = find_x_myopic(fullObs_cumulativeTime, fullObs_cumulativeQuantity);
            
            v_max = G_F(n, x_opt, fullObs_cumulativeTime, fullObs_cumulativeQuantity);
            
            
            if (n==1)
            {
                cout << x_opt << "\t" << v_max  << "\t";
                file << x_opt << "\t" << v_max  << "\t";
            }
            
            
            //#pragma omp critical (v_map)
            { v_map.emplace(parameters, v_max); }
            
        }
        
    }
    
    return v_max;
}
开发者ID:tong-wang,项目名称:NVLearning,代码行数:46,代码来源:NVLearning_Full.cpp

示例2: get_legals

/***********************************************************************
 * Internal format to return the legals in a structure that is easy
 * to check if some move is legal.
 ***********************************************************************/
void State::get_legals(boost::unordered_map<Player, boost::unordered_set<Move> >& result) const
{
    typedef boost::unordered_map<Player, boost::unordered_set<Move> > tmp_t;

    result.clear();
    std::vector<PlayerMove> legalMoves;
    legals(std::back_inserter(legalMoves));

    for(std::vector<PlayerMove>::iterator pm = legalMoves.begin(); pm != legalMoves.end(); pm++) {
        tmp_t::iterator iter_moves(result.find(pm->first));
        if(iter_moves == result.end()) {
            std::pair<tmp_t::iterator, bool> ok = result.emplace(pm->first, boost::unordered_set<Move>());
            ok.first->second.emplace(pm->second);
        } else {
            iter_moves->second.emplace(pm->second);
        }
    }
}
开发者ID:AbdallahS,项目名称:ggp-hsfc,代码行数:22,代码来源:hsfc.cpp


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