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


C++ TMap::find方法代码示例

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


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

示例1: check

bool check ()
{
     TMap :: iterator  Iter , Iter2;
     Map2 = Map;
     string next;
     int  len = Ans.length () , len1;
     for ( Iter = Map2.begin (); Iter != Map2.end (); Iter ++ )
         for ( ; Iter->second; ) {
             Iter -> second --;
             len1 = Iter->first.length ();
             
             if ( len1 > len ) return false;
             if ( Ans.substr ( 0 , len1 ) == Iter->first ) {
                  next = Ans.substr ( len1 , len - len1 );
                  Iter2 = Map2.find ( next );
                  if ( Iter2 == Map2.end () || Iter2->second == 0 ) break;
                  Iter2->second --;
                  continue;
             }             
             if ( Ans.substr ( len - len1 , len1 ) == Iter->first ) {
                  next = Ans.substr ( 0 , len - len1 );
                  Iter2 = Map2.find ( next );
                  if ( Iter2 == Map2.end () || Iter2->second == 0 ) break;
                  Iter2->second --;
                  continue;
             }
             return false;
         }
     return true;
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:30,代码来源:p1832.cpp

示例2: find

 iterator find(const key_type& key) {
     TMapIterator iter = m_Map.find(key);
     if ( iter != m_Map.end() ) {
         x_MarkUsed(iter);
     }
     return iterator(iter);
 }
开发者ID:swuecho,项目名称:igblast,代码行数:7,代码来源:limited_size_map.hpp

示例3: solve

void solve ()
{
     TMap  :: iterator Iter;
     Map.clear ();
     for ( int i = 0; i < N; i ++ ) {
         Iter = Map.find ( Info [i] );
         if ( Iter == Map.end () ) Map [Info [i]] = 0 , Iter = Map.find ( Info [i] );
         Iter->second ++;
     }
     for ( int i = 0; i < N; i ++ )
         for ( int j = 0; j < N; j ++ ) if ( i != j ) {
             Ans = Info [i] + Info [j];
             if ( check ()) {
                  printf ( "%s\n" , Ans.c_str ());
                  return;
             }
         }
}
开发者ID:3013216027,项目名称:zoj-solutions-fish_ball,代码行数:18,代码来源:p1832.cpp

示例4: tryGetValue

inline bool tryGetValue(TMap &m, TKey key, TValue &u)
{
    auto it = m.find(key);
    if(it!=m.end())
    {
        u = it->second;
        return true;
    }
    return false;
}
开发者ID:vovaprog,项目名称:algo,代码行数:10,代码来源:605a_3.cpp

示例5:

/**
 * insert
 */                                        
BOOST_AUTO_TEST_CASE_TEMPLATE(stest_insert, TMap, test_types) {
    // insert x values, insert them again, check values
    using char_tt = typename TMap::char_type; 
    
    const size_t nb_values = 100000;
    TMap set;
    typename TMap::iterator it;
    bool inserted;
    
    for(size_t i = 0; i < nb_values; i++) {
        std::tie(it, inserted) = set.insert(utils::get_key<char_tt>(i));
        
        BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
        BOOST_CHECK(inserted);
    }
    BOOST_CHECK_EQUAL(set.size(), nb_values);
    
    for(size_t i = 0; i < nb_values; i++) {
        std::tie(it, inserted) = set.insert(utils::get_key<char_tt>(i));
        
        BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
        BOOST_CHECK(!inserted);
    }
    
    for(size_t i = 0; i < nb_values; i++) {
        it = set.find(utils::get_key<char_tt>(i));
        
        BOOST_CHECK(it != set.end());
        BOOST_CHECK_EQUAL(it.key(), (utils::get_key<char_tt>(i)));
    }
    
    for(auto it = set.begin(); it != set.end(); ++it) {
        auto it_find = set.find(it.key());
        
        BOOST_CHECK(it_find != set.end());
        BOOST_CHECK_EQUAL(it_find.key(), it.key());
    }
}
开发者ID:LinJM,项目名称:hat-trie,代码行数:41,代码来源:trie_set_tests.cpp

示例6: outputHLSLSamplerUniformGroup

void UniformHLSL::outputHLSLSamplerUniformGroup(
    TInfoSinkBase &out,
    const HLSLTextureSamplerGroup textureGroup,
    const TVector<const TIntermSymbol *> &group,
    const TMap<const TIntermSymbol *, TString> &samplerInStructSymbolsToAPINames,
    unsigned int *groupTextureRegisterIndex)
{
    if (group.empty())
    {
        return;
    }
    unsigned int groupRegisterCount = 0;
    for (const TIntermSymbol *uniform : group)
    {
        const TType &type   = uniform->getType();
        const TString &name = uniform->getSymbol();
        unsigned int registerCount;

        // The uniform might be just a regular sampler or one extracted from a struct.
        unsigned int samplerArrayIndex = 0u;
        const Uniform *uniformByName = findUniformByName(name);
        if (uniformByName)
        {
            samplerArrayIndex = assignUniformRegister(type, name, &registerCount);
        }
        else
        {
            ASSERT(samplerInStructSymbolsToAPINames.find(uniform) !=
                   samplerInStructSymbolsToAPINames.end());
            samplerArrayIndex = assignSamplerInStructUniformRegister(
                type, samplerInStructSymbolsToAPINames.at(uniform), &registerCount);
        }
        groupRegisterCount += registerCount;

        if (type.isArray())
        {
            out << "static const uint " << DecorateIfNeeded(uniform->getName()) << ArrayString(type)
                << " = {";
            for (unsigned int i = 0u; i < type.getArraySize(); ++i)
            {
                if (i > 0u)
                    out << ", ";
                out << (samplerArrayIndex + i);
            }
            out << "};\n";
        }
        else
        {
            out << "static const uint " << DecorateIfNeeded(uniform->getName()) << " = "
                << samplerArrayIndex << ";\n";
        }
    }
    TString suffix = TextureGroupSuffix(textureGroup);
    // Since HLSL_TEXTURE_2D is the first group, it has a fixed offset of zero.
    if (textureGroup != HLSL_TEXTURE_2D)
    {
        out << "static const uint textureIndexOffset" << suffix << " = "
            << (*groupTextureRegisterIndex) << ";\n";
        out << "static const uint samplerIndexOffset" << suffix << " = "
            << (*groupTextureRegisterIndex) << ";\n";
    }
    out << "uniform " << TextureString(textureGroup) << " textures" << suffix << "["
        << groupRegisterCount << "]"
        << " : register(t" << (*groupTextureRegisterIndex) << ");\n";
    out << "uniform " << SamplerString(textureGroup) << " samplers" << suffix << "["
        << groupRegisterCount << "]"
        << " : register(s" << (*groupTextureRegisterIndex) << ");\n";
    *groupTextureRegisterIndex += groupRegisterCount;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:69,代码来源:UniformHLSL.cpp


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