本文整理汇总了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;
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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());
}
}
}
示例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;
}