本文整理汇总了C++中list_t::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ list_t::erase方法的具体用法?C++ list_t::erase怎么用?C++ list_t::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类list_t
的用法示例。
在下文中一共展示了list_t::erase方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
}
}
示例2: remove
/** Remove an element from the cache. */
void remove (const key_type& k)
{
auto found (map_.find(k));
if (found == map_.end())
return;
list_.erase(found->second);
map_.erase(found);
--size_;
}
示例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: destruct
void MEM_CacheLimiterCClass::destruct(void *data, list_t::iterator it)
{
data_destructor(data);
cclass_list.erase(it);
}