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


C++ Bag::clear方法代码示例

本文整理汇总了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();
}
开发者ID:msullivan,项目名称:rmc-compiler,代码行数:7,代码来源:epoch_c11simp.cpp

示例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;
}
开发者ID:Network-Dynamics,项目名称:adevs,代码行数:46,代码来源:test.cpp

示例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;
}
开发者ID:PaulLaliberte,项目名称:Data-Structures,代码行数:19,代码来源:bag_test.cpp

示例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;
}
开发者ID:quackle,项目名称:quackle,代码行数:20,代码来源:board.cpp


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