本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
//.........这里部分代码省略.........