本文整理汇总了C++中LList::valid方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::valid方法的具体用法?C++ LList::valid怎么用?C++ LList::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::valid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}