本文整理汇总了C++中Bag::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Bag::clear方法的具体用法?C++ Bag::clear怎么用?C++ Bag::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bag
的用法示例。
在下文中一共展示了Bag::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectBag
void RealLocalGarbage::collectBag(Bag &bag) {
for (auto f : bag) {
f();
}
// XXX: should we shrink capacity?
bag.clear();
}
示例2: main
int main()
{
model = new Wrapper(new SimpleModel());
Simulator<External*>* sim = new Simulator<External*>(model);
Listener* l = new Listener();
sim->addEventListener(l);
// First input/output series. Internal event test.
l->setExpected(1.0,FAST,1);
Event<External*> e;
e.model = model;
e.value = new External(FAST,1);
Bag<Event<External*> > x;
x.insert(e);
sim->computeNextState(x,0.0);
assert(sim->nextEventTime() == 1.0);
sim->execNextEvent();
assert(output_happened);
output_happened = false;
// Second input/output series. External event test.
l->setExpected(3.5,SLOW,1);
x.clear();
e.value = new External(SLOW,1);
x.insert(e);
sim->computeNextState(x,1.5);
assert(!output_happened);
assert(sim->nextEventTime() == 3.5);
sim->execNextEvent();
assert(output_happened);
output_happened = false;
// Third input/output series. Confluent event test
l->setExpected(5.5,SLOW,2);
x.clear();
e.value = new External(STOP,1);
x.insert(e);
assert(sim->nextEventTime() == 5.5);
sim->computeNextState(x,sim->nextEventTime());
assert(output_happened);
assert(sim->nextEventTime() == DBL_MAX);
// Done. Try to clean up.
assert(External::num_existing == 3);
delete model;
delete l;
delete sim;
assert(Internal::num_existing == 0);
return 0;
}
示例3: main
int main()
{
Bag b;
// Bag a(10); //*
bag_type value;
cout << "Let's create a bag with only one element: " << endl;
b.insert(5); //inserts one element into the bag
cout << b.size() << " element(s) in bag the bag." << endl;
b.clear();
cout << b.size() << " element(s) in the bag after b.clear()." << endl;
do {
value = rand() % 6 + 1;
} while(b.insert(value));
cout << b.size() << " element(s) in the bag." << endl;
b.clear();
cout << b.size() << " element(s) in the bag after b.clear()." << endl;
}
示例4: tilesOnBoard
Bag Board::tilesOnBoard() const
{
Bag ret;
ret.clear();
for (int row = 0; row < m_height; row++)
{
for (int col = 0; col < m_width; col++)
{
if (m_letters[row][col] != QUACKLE_NULL_MARK)
{
LetterString letters;
letters += m_isBlank[row][col]? QUACKLE_BLANK_MARK : m_letters[row][col];
ret.toss(letters);
}
}
}
return ret;
}