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


C++ LList::size方法代码示例

本文整理汇总了C++中LList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::size方法的具体用法?C++ LList::size怎么用?C++ LList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LList的用法示例。


在下文中一共展示了LList::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{

	LList<int> llist;
	LList<int>::iterator it = llist.begin();
	LList<int>::iterator it2 = llist.end();
	it2 = LList<int>::iterator(it);
#if 1
	it  = llist.insert(it,1);
	it  = llist.insert(it,2);
	it  = llist.insert(it,3);
	it = llist.begin();
	cout<<"--------insert-------------"<<endl;
	for(;it != llist.end();it++)
		cout<<*it<<endl;

	llist.clear();

	llist.push_back(11);
	llist.push_back(12);
	llist.push_back(13);
	llist.erase(llist.begin());
	cout<<"--------push_back-------------"<<endl;
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	llist.clear();
	cout<<"--------size-------------"<<llist.size()<<endl;
	llist.push_back(14);
	llist.push_back(15);
	llist.push_back(16);
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	cout<<"--------transfer-------------"<<llist.size()<<endl;
	LList<int>::iterator first= ++llist.begin();
	LList<int>::iterator last= llist.end();
	llist.transfer(++llist.begin(),++first,last);
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
	cout<<"--------reverse-------------"<<llist.size()<<endl;
	llist.reverse();
	for(it=llist.begin();it != llist.end();it++)
		cout<<*it<<endl;
#endif		
	return 0;
}
开发者ID:loganwu,项目名称:ServerForMogan,代码行数:45,代码来源:listExp.cpp

示例2: main

int main() {
	LList<Pokemon> pokedex;
	pokedex.push_back(Pokemon(1, "Bulbasaur"));
	pokedex.push_back(Pokemon(4, "Charmander"));
	pokedex.push_back(Pokemon(7, "Squirtle"));

	for (int i = 0; i < pokedex.size(); i++) {
		std::cout << pokedex.get(i).name << std::endl;
	}

	return 0;
}
开发者ID:wjymtg,项目名称:HelloWorld,代码行数:12,代码来源:main.cpp

示例3: Oplus

void LList::Oplus(LList& L1)
{
	int i,j,k,pos;
	int AddDim = L1.size();
	int OldDim = dim;
	int OldClassSize=0;
	if (OldDim!=0) OldClassSize = data[0].Gname.size();
        
	LevelArray OldBody;
        Level TmpLevel;
        
	if (OldDim != 0)
	{
                OldBody.assign(OldDim+1,TmpLevel);
		for (i=0;i<=OldDim;i++)
		{
                        OldBody[i].Gname.assign(OldClassSize,1);
			for (j=0;j<OldClassSize;j++)
				OldBody[i].Gname[j] = data[i].Gname[j];
			OldBody[i].Gnr = data[i].Gnr;
		}
	}

	dim = (AddDim+1)*(OldDim+1) - 1;
        
        data.assign(dim+1,TmpLevel);
        
	pos=0;
	for (i=0;i<=OldDim;i++)
	{
		for (j=0;j<=AddDim;j++)
		{
                        data[pos].Gname.assign(OldClassSize+1,1);
			if (OldDim!=0) for (k=0;k<OldClassSize;k++) data[pos].Gname[k] = OldBody[i].Gname[k];
                        
			data[pos].Gname[OldClassSize] = L1[j]->Gname[0];
			if (OldDim!=0)
				data[pos].Gnr = OldBody[i].Gnr + L1[j]->Gnr;
			else
				data[pos].Gnr = L1[j]->Gnr;
			pos++;
		}
	}
        
	OldBody.erase(OldBody.begin(),OldBody.end());
}
开发者ID:ppdewolf,项目名称:tauhitas,代码行数:46,代码来源:ALList.cpp

示例4: ParseMemoryLeakFile

void ParseMemoryLeakFile(const char *_inputFilename, const char *_outputFilename)
{
	/* */
	/* Start up */
	/* */

	RedBlackTree<char *, int> combined;
	RedBlackTree<char *, int> frequency;
	int                       unrecognised = 0;

	/* */
	/* Open the file and start parsing */
	/* */

	FILE                     *memoryfile = fopen(_inputFilename, "rb");

	while (memoryfile && !feof(memoryfile))	{
		char thisline[1024];

		fgets(thisline, 1024, memoryfile);

		if (!strncmp(thisline, " Data:", 6) == 0) { /* This line is a data line - useless to us */
			if (strchr(thisline, ':')) {                               /* This line does not have a source file location - useless to us */
				/* Get the size */

				char *lastcomma = strrchr(thisline, ',');
				if (lastcomma == 0) continue;

				char *ssize = lastcomma + 2;
				int   size;
				char  unused[32];

				sscanf(ssize, "%d %s", &size, unused);

				/* Get the source file name */

				char *sourcelocation = thisline;
				char *colon = strrchr(thisline, ':');

				*(colon - 1) = '\x0';

				/* Put the result into our BTree */

				int   result = 0;
				bool  found = combined.find(sourcelocation, result);

				if (found)
					combined.replace(sourcelocation, result + size);
				else
					combined.insert(sourcelocation, size);

				found = frequency.find(sourcelocation, result);

				if (frequency.exists(sourcelocation))
					frequency.replace(sourcelocation, result + size);
				else
					frequency.insert(sourcelocation, 1);
			} else {
				char *lastcomma = strrchr(thisline, ',');

				if (lastcomma) {
					char *ssize = lastcomma + 2;
					int   size;
					char  unused[32];

					sscanf(ssize, "%d %s", &size, unused);

					unrecognised += size;
				}
			}
		}
	}

	fclose(memoryfile);


	/* */
	/* Sort the results into a list */
	/* */

	LList<char *>   sorted;
	DArray<char *> *dataI = combined.ConvertIndexToDArray();
	DArray<int>    *dataD = combined.ConvertToDArray();

	int             totalsize = 0;

	for (size_t i = 0; i < dataI->size(); i++) {
		if (dataI->valid(i)) {
			char *newsource = dataI->get(i);
			int   newsize = dataD->get(i);

			totalsize += newsize;
			bool  inserted = false;

			for (size_t i = 0; i < sorted.size(); i++) {
				char *existingsource = sorted.get(i);
				int   existingsize;

				combined.find(existingsource, existingsize);

//.........这里部分代码省略.........
开发者ID:skydevgit,项目名称:crisscross,代码行数:101,代码来源:universal_include.cpp


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