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


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

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


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

示例1: TestSort_LList

int TestSort_LList(Sorter<int> *_sorter)
{
	LList<int>     *llist = new LList<int>();

	for (int i = 0; i < SORT_ITEMS; i++) {
		llist->insert(rand());
	}

	llist->sort(_sorter);

	for (int i = 0; i < SORT_ITEMS - 1; i++) {
		TEST_ASSERT(llist->get(i) <= llist->get(i+1));
	}

	delete llist;
	return 0;
}
开发者ID:amoylel,项目名称:crisscross,代码行数:17,代码来源:sort.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: connect

int IRC::connect(char *server,char *nick,u_short port,char *pass)
{
	ccerr = conn->Connect(server,port);
	if (ccerr != 0)
		return ccerr;
	this->my_server = server;
	if (pass != NULL) {
		strcpy(this->msg_buf,"PASS ");
		strcat(this->msg_buf,pass);
		this->send(this->msg_buf);
	}
	this->nick(nick);
	this->my_nick = nick;
	this->user(nick,"0",this->my_server);
	char *line = this->readline();
	LList<char *> results = this->split(line," ");
	int i = 0;
	while (!results.valid(1)) {
		char *line = this->readline();
		results = this->split(line," ");
	}
	while (!strcmp(results.get(1),"001")) {
	    if (strcmp(results.get(1),"PING")) {
		    strcpy(this->msg_buf,"PONG ");
		    strcat(this->msg_buf,results.get(2));
		    this->send(this->msg_buf);
	    } else if (strcmp(results.get(1),"433") || strcmp(results.get(1),"432")) {
		    stringstream out;
		    out << ++i;
		    this->nick(strcat(nick,out.str().c_str()));
		    this->my_nick = strcat(nick,out.str().c_str());
	    }
	    line = this->readline();
	    results = this->split(line," ");
	}

	strcpy(this->msg_buf,"WHOIS ");
	strcat(this->msg_buf,this->my_nick);
	this->send(this->msg_buf);
	do {
		line = this->readline();
		results = this->split(line," ");
		if (strcmp(results.get(1),"311"))
			this->my_host = strcat(results.get(4),strcat("@",results.get(5)));
	} while (this->my_host == NULL);

	return 0;
}
开发者ID:EddieRingle,项目名称:idlebot,代码行数:48,代码来源:irc.cpp

示例4: TestInsertionSort_LList

int TestInsertionSort_LList()
{
	LList<int>         *llist = new LList<int>();

	llist->insert(4);
	llist->insert(2);
	llist->insert(0);
	llist->insert(3);
	llist->insert(1);

	InsertionSort<int> *is = new InsertionSort<int>();
	llist->sort(is);
	delete is;

	for (int i = 0; i < 5; i++) {
		TEST_ASSERT(llist->get(i) == i);
	}

	delete llist;
	return 0;
}
开发者ID:skydevgit,项目名称:crisscross,代码行数:21,代码来源:insertionsort.cpp

示例5: TestQuickSort_LList

int TestQuickSort_LList()
{
	LList<int>     *llist = new LList<int>();

	llist->insert(4);
	llist->insert(2);
	llist->insert(0);
	llist->insert(3);
	llist->insert(1);

	QuickSort<int> *qs = new QuickSort<int>();
	llist->sort(qs);
	delete qs;

	for (int i = 0; i < 5; i++) {
		TEST_ASSERT(llist->get(i) == i);
	}

	delete llist;
	return 0;
}
开发者ID:prophile,项目名称:crisscross,代码行数:21,代码来源:quicksort.cpp

示例6: TestShellSort_LList

int TestShellSort_LList()
{
	LList<int>     *llist = new LList<int>();

	llist->insert(4);
	llist->insert(2);
	llist->insert(0);
	llist->insert(3);
	llist->insert(1);

	ShellSort<int> *ss = new ShellSort<int>();
	llist->sort(ss);
	delete ss;

	for (int i = 0; i < 5; i++) {
		TEST_ASSERT(llist->get(i) == i);
	}

	delete llist;
	return 0;
}
开发者ID:prophile,项目名称:crisscross,代码行数:21,代码来源:shellsort.cpp

示例7: TestLList

int TestLList()
{
	LList<char *> *llist = new LList<char *>();
	TEST_ASSERT(llist);

	TEST_ASSERT(!llist->valid((unsigned int)-1));
	TEST_ASSERT(!llist->valid(1));
	TEST_ASSERT(!llist->valid(0));

	llist->insert(newStr("one"));
	llist->insert(newStr("two"));
	llist->insert(newStr("three"));
	llist->insert(newStr("four"));

	TEST_ASSERT(strcmp(llist->get(0), "one") == 0);
	TEST_ASSERT(strcmp(llist->get(2), "three") == 0);
	TEST_ASSERT(strcmp(llist->get(3), "four") == 0);
	TEST_ASSERT(strcmp(llist->get(1), "two") == 0);

	delete [] llist->get(1);
	llist->remove(1);

	TEST_ASSERT(strcmp(llist->get(0), "one") == 0);
	TEST_ASSERT(strcmp(llist->get(1), "three") == 0);
	TEST_ASSERT(strcmp(llist->get(2), "four") == 0);

	while (llist->valid(0))	{
		delete [] llist->get(0);
		llist->remove(0);
	}

	TEST_ASSERT(!llist->valid((unsigned int)-1));
	TEST_ASSERT(!llist->valid(1));
	TEST_ASSERT(!llist->valid(0));

	delete llist;

	return 0;
}
开发者ID:DanLinder,项目名称:crisscross,代码行数:39,代码来源:llist.cpp

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