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


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

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


在下文中一共展示了TMap::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: TestRangeMap

void CTestRangeMap::TestRangeMap(void) const
{
    Filling("CRangeMap");

    typedef CRangeMultimap<CConstRef<CObject> > TMap;
    typedef TMap::const_iterator TMapCI;

    TMap m;

    // fill
    for ( int count = 0; count < m_RangeNumber; ) {
        TRange range = RandomRange();
        m.insert(TMap::value_type(range, CConstRef<CObject>(0)));
        ++count;
        Added(range);
    }
    
    if ( m_PrintSize ) {
        Filled(m.size());
        // Stat(m.stat());
    }

    for ( TMapCI i = m.begin(); i; ++i ) {
        FromAll(i.GetInterval());
    }

    size_t scannedCount = 0;
    for ( int count = 0; count < m_ScanCount; ++count ) {
        for ( int pos = 0; pos <= m_Length + 2*m_RangeLength;
              pos += m_ScanStep ) {
            TRange range;
            range.Set(pos, pos + m_ScanLength - 1);
            
            StartFrom(range);
            
            for ( TMapCI i = m.begin(range); i; ++i ) {
                From(range, i.GetInterval());
                ++scannedCount;
            }
        }
    }
    PrintTotalScannedNumber(scannedCount);

    End();
}
开发者ID:,项目名称:,代码行数:45,代码来源:

示例3: MakeUnique

//----------------------------------------------------------------------------
void CIsoSurface::MakeUnique (std::vector<TVector3D>& rkVA,
    std::vector<TriangleKey>& rkTA)
{
    int iVQuantity = (int)rkVA.size();
    int iTQuantity = (int)rkTA.size();
    if ( iVQuantity == 0 || iTQuantity == 0 )
        return;

    // use a hash table to generate unique storage
    VMap kVMap;
    VMapIterator pkVIter;
    for (int iV = 0, iNextVertex = 0; iV < iVQuantity; iV++)
    {
        // keep only unique vertices
        std::pair<VMapIterator,bool> kResult = kVMap.insert( std::make_pair(rkVA[iV],iNextVertex) );
        if ( kResult.second == true )
            iNextVertex++;
    }

std::cerr << "Found " << kVMap.size() << " vertices" << std::endl;
    
    // use a hash table to generate unique storage
    TMap kTMap;
    TMapIterator pkTIter;
    for (int iT = 0, iNextTriangle = 0; iT < iTQuantity; iT++)
    {
        // replace old vertex indices by new ones
        TriangleKey& rkTri = rkTA[iT];
        pkVIter = kVMap.find(rkVA[rkTri.V[0]]);
        assert( pkVIter != kVMap.end() );
        rkTri.V[0] = pkVIter->second;
        pkVIter = kVMap.find(rkVA[rkTri.V[1]]);
        assert( pkVIter != kVMap.end() );
        rkTri.V[1] = pkVIter->second;
        pkVIter = kVMap.find(rkVA[rkTri.V[2]]);
        assert( pkVIter != kVMap.end() );
        rkTri.V[2] = pkVIter->second;

        // keep only unique triangles
        std::pair<TMapIterator,bool> kResult = kTMap.insert(
            std::make_pair(rkTri,iNextTriangle));
        if ( kResult.second == true )
            iNextTriangle++;
    }

    // pack the vertices
    rkVA.resize(kVMap.size());
    for (pkVIter = kVMap.begin(); pkVIter != kVMap.end(); pkVIter++)
        rkVA[pkVIter->second] = pkVIter->first;

    // pack the triangles
    rkTA.resize(kTMap.size());
    for (pkTIter = kTMap.begin(); pkTIter != kTMap.end(); pkTIter++)
        rkTA[pkTIter->second] = pkTIter->first;
}
开发者ID:BackupTheBerlios,项目名称:aips-svn,代码行数:56,代码来源:cisosurface.cpp

示例4:

/**
 * 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

示例5: begin

 const_iterator begin(void) const {
     return const_iterator(m_Map.begin());
 }
开发者ID:swuecho,项目名称:igblast,代码行数:3,代码来源:limited_size_map.hpp


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