本文整理汇总了C++中TList::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::Append方法的具体用法?C++ TList::Append怎么用?C++ TList::Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::Append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateBuffer
void
Client::StartWorker(workMode pMode) {
int msgsize = 1 + (int) (250000.0 * (rand() / (RAND_MAX + 1.0)));
char* buf = CreateBuffer(&msgsize);
//fill data part of buffer with random bytes
for (int i = 2; i < (msgsize); i++) {
buf[i] = i % 256;
}
if (pMode == THREADS) {
ThreadWorker* c = new ThreadWorker(m_host,buf,msgsize+2);
if (c->Create() != wxTHREAD_NO_ERROR) {
wxLogError(wxT("Cannot create more threads"));
} else {
c->Run();
m_threadWorkers.Append(c);
}
} else {
EventWorker* e = new EventWorker(m_host,buf,msgsize+2);
e->Run();
m_eventWorkers.Append(e);
}
m_statConnecting++;
}
示例2: Search
void TAstar::Search()
{
TAstar T = *this; //初始结点
T.f = T.Calcuf(); //初始结点的估价函数
TList<TAstar> L; //建立队列
L.Append(T); //初始结点入队
int head = 0, tail = 0; //队列头和尾指针
while (head <= tail) //队列不空则循环
{
for (int i = 0; i<4; i++) //空格可能移动方向
{
T = L.GetData(head); //去队列头结点
if (T.h == 0) //是目标结点
{
T.Printl(L);//输出搜索路径
//T.Printf(); //输出目标状态
//printf("%d\n", T.getZeroPos());
this->rs.push_back(T.getZeroPos());
return; //结束
}
if (T.Expend(i)) //若结点可扩展
{
int k = T.Repeat(L); //返回与已扩展结点重复的序号
if (k<head) //如果是不能扩展的结点
continue; //丢弃
T.last = head; //不是不能扩展的结点,记录父结点
T.f = T.Calcuf(); //计算f
if (k <= tail) //新结点与可扩展结点重复
{
TAstar Temp = L.GetData(k);
if (Temp.g>T.g) //比较两结点g值
L.SetData(T, k); //保留g值小的
continue;
}
T.Sort(L, head); //新结点插入可扩展结点队列
tail++; //队列尾指针后移
}
}
head++; //一个结点不能再扩展,队列头指针指向下一结点
}
}
示例3: wxStrdup
void
Client::StartWorker(workMode pMode, const wxString& pMessage) {
char* tmpbuf = wxStrdup(pMessage.mb_str());
int msgsize = strlen(tmpbuf);
char* buf = CreateBuffer(&msgsize);
memset(buf+2,0x0,msgsize);
memcpy(buf+2,tmpbuf,msgsize);
free(tmpbuf);
if (pMode == THREADS) {
ThreadWorker* c = new ThreadWorker(m_host,buf,msgsize+2);
if (c->Create() != wxTHREAD_NO_ERROR) {
wxLogError(wxT("Cannot create more threads"));
} else {
c->Run();
m_threadWorkers.Append(c);
}
} else {
EventWorker* e = new EventWorker(m_host,buf,msgsize+2);
e->Run();
m_eventWorkers.Append(e);
}
m_statConnecting++;
}