本文整理汇总了C++中TList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::empty方法的具体用法?C++ TList::empty怎么用?C++ TList::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoTestFrontBack
std::string DoTestFrontBack(size_t n) {
TCounter::Reset();
{
constexpr int M = 10;
TCounter data[M];
TList<TCounter, std::allocator<TCounter>> lst;
for (size_t i = 0; i < n; ++i) {
lst.push_back(TCounter(data[i % M]));
}
if (lst.size() != n)
return "lst.size(): wrong answer";
if (lst.back().GetData() != data[(n + M - 1) % M].GetData())
return "lst.back(): wrong answer";
if (lst.front().GetData() != data[0].GetData())
return "lst.front(): wrong answer";
while (!lst.empty())
lst.pop_back();
for (size_t i = 0; i < n; ++i) {
lst.push_front(TCounter(data[i % M]));
}
if (lst.size() != n)
return "lst.size(): wrong answer";
if (lst.front().GetData() != data[(n + M - 1) % M].GetData())
return "lst.back(): wrong answer";
if (lst.back().GetData() != data[0].GetData())
return "lst.front(): wrong answer";
while (!lst.empty())
lst.pop_front();
}
TCounter::CheckTotalOperationsCount(n * 10 + 100, n + 100);
return TCounter::GetAllErrors();
}
示例2: CascadeTimers
int TimerMaster::CascadeTimers(TimerVec *v, int index) {
TList *l = &(*v)[index];
for (TList::iterator it = l->begin();
it != l->end();) {
TimerSlot *s = &*it;
++it;
s->unlink();
InternalAddTimer(s, s->weak_timer, s->jiffies);
}
CHECK(l->empty());
return index;
}
示例3: DoTestInsertRemoveEmpty
std::string DoTestInsertRemoveEmpty(size_t n) {
TCounter::Reset();
{
TList<TCounter, std::allocator<TCounter>> lst;
for (size_t i = 0; i < n; ++i) {
TList<TCounter, std::allocator<TCounter>>::iterator it = lst.begin();
for (size_t j = 0; j < i / 2; ++j)
++it;
lst.insert(it, TCounter());
}
if (lst.size() != n)
return "lst.size(): wrong answer";
while (!lst.empty())
lst.erase(lst.begin());
}
TCounter::CheckTotalOperationsCount(n * 5 + 100, n + 100);
return TCounter::GetAllErrors();
}