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


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

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


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

示例1: found

    /** Fetch an element from the cache.
     *  If the key does not exist yet, a new empty element will be
     *  created. */
    mapped_type& operator[] (const key_type& k)
    {
        auto found (map_.find(k));
        if (found == map_.end())
        {
            list_.push_front(pair_t(k, mapped_type()));
            map_[k] = list_.begin();
            ++size_;

            return list_.begin()->second;
        }
        list_.splice(list_.begin(), list_, found->second);

        return found->second->second;
    }
开发者ID:friederschueler,项目名称:hexahedra,代码行数:18,代码来源:lru_cache.hpp

示例2: touch

 /** Mark an element as recently used. */
 void touch (const key_type& k)
 {
     auto found (map_.find(k));
     assert(found != map_.end());
     if (found != map_.end())
         list_.splice(list_.begin(), list_, found->second);
 }
开发者ID:friederschueler,项目名称:hexahedra,代码行数:8,代码来源:lru_cache.hpp

示例3: remove_even

static void remove_even(list_t &l) {
    bool even = false;
    for (auto it = l.begin(); it != l.end();) {
        if (even)
            it = l.erase(it);
        else
            ++it;

        even = !even;
    }
}
开发者ID:SubutaiBogatur,项目名称:CPP-Homework,代码行数:11,代码来源:tests.cpp

示例4: prune_if

    void prune_if (size_t max_size, pred op)
    {
        if (list_.empty())
            return;

        auto i (std::prev(list_.end()));
        while (size_ > max_size)
        {
            if (op(*i))
            {
                map_.erase(i->first);
                i = list_.erase(i);
                --size_;
            }
            if (i == list_.begin())
                return;

            --i;
        }
    }
开发者ID:friederschueler,项目名称:hexahedra,代码行数:20,代码来源:lru_cache.hpp

示例5: comb

void comb(list_t &L,traverse_tree_fun f,void *data=NULL) {
  if (L.size()==1) {
    f(*L.begin(),data);
    return;
  } 
  int n=L.size();
  for (int j=0; j<n-1; j++) {
    for (int k=j+1; k<n; k++) {
      btree_t T;
      T.insert(T.begin(),-1);
      node_t m = T.begin();

      pos_t pk=L.begin();
      for (int kk=0; kk<k; kk++) pk++;
      T.splice(m.left(),pk->begin());
      L.erase(pk);

      pos_t pj=L.begin();
      for (int jj=0; jj<j; jj++) pj++;
      T.splice(m.right(),pj->begin());
      L.erase(pj);

      pos_t p = L.insert(L.begin(),btree_t());
      p->splice(p->begin(),T.begin());

      comb(L,f,data);

      p = L.begin();
      m = T.splice(T.begin(),p->begin());
      L.erase(p);

      pj=L.begin();
      for (int jj=0; jj<j; jj++) pj++;
      pj = L.insert(pj,btree_t());
      pj->splice(pj->begin(),m.right());
	
      pk=L.begin();
      for (int kk=0; kk<k; kk++) pk++;
      pk = L.insert(pk,btree_t());
      pk->splice(pk->begin(),m.left());

    }
  }
}
开发者ID:Malows,项目名称:aedcode,代码行数:44,代码来源:allabc.cpp

示例6: solve

void solve(int dataId)
{
    int s = -1, t= -1, use = -1;
    for(int i=0;i<26;i++)
    {
        int outd = 0, ind=0;
        for(int j=0;j<26;j++)
        {
            outd += links[i][j].size();
            ind += links[j][i].size();
        }
        if(outd || ind) use = i;
        if(outd > ind+1 || ind > outd+1)
        {
            cout << "IMPOSSIBLE" << endl;
            return;
        }
        if(outd > ind)
        {
            if(s != -1)
            {
                cout << "IMPOSSIBLE" << endl;
                return;
            }
            s = i;
        }
        if(ind > outd)
        {
            if(t != -1)
            {
                cout << "IMPOSSIBLE" << endl;
                return;
            }
            t = i;
        }
    }
    if(s == -1) s = t = use;

    if(walk2(output.end(), s, t) == -1)
    {
        cout << "IMPOSSIBLE" << endl;
        return;
    }
    output.pb(mp("", t));
    foreach(it, output)
    {
        if(pump(it) == -1)
        {
            cout << "IMPOSSIBLE" << endl;
            return;
        }
    }

    for(int i=0;i<30;i++) for(int j=0;j<30;j++) if(links[i][j].size())
    {
        cout << "IMPOSSIBLE" << endl;
        return;
    }

    output.pop_back();
    list_t::iterator it = output.begin();
    do
    {
        cout << it->first;
        ++it;
        if(it == output.end()) break;
        cout << " ";
    } while(true);
    cout << endl;
}
开发者ID:blmarket,项目名称:icpc,代码行数:70,代码来源:WORDCHAIN.cpp


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