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


C++ Match::insert方法代码示例

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


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

示例1: fillMatching

 // Method fills the map matching, which is a multimap of the highest
 // scoring words for a given line.  This is because one line may give
 // multiple same-scoring words that are all 'the best' word to play
 // for a move, such as how tiles 'abcdefg' give badge, cafe, and face,
 // which are each worth 9 points.  Method will continue to add new 
 // same-scoring words until a word of higher score is found, which resets
 // the map for the particular key.
 void fillMatching(const string &line, const string &s)
 {
   wordScore = myScored.find(s)->second; // set wordScore to score of word
   if(count == 0)
   {
     highScore = wordScore;// set highScore to score of word
     matching.insert(Match::value_type(line, s)); //insert into map
     setCount(); // increase count
   }//if(count == 0)
   else
   {
     for(Match::const_iterator itr = matching.begin(); itr != matching.end(); itr++)
       if(s == itr->second)
         return;
        
     if(wordScore > highScore)
     {
       matching.erase(line);
       count = 0;
       matching.insert(Match::value_type(line, s)); //insert into map
       highScore = wordScore;
       setCount();
     }// if(wordScore > highScore)
     else
     {
       if(wordScore == highScore)
       {
         matching.insert(Match::value_type(line, s)); //insert into map
         setCount(); //increment count
       } // if(wordScore == highScore)   
       else
         return; // wordScore < highScore, so ignore and leave
     }// else wordScore <= highScore
   }// else count > 0
   return;
 } // void fillMatching()
开发者ID:elowe,项目名称:School,代码行数:43,代码来源:scrabble.cpp


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