本文整理匯總了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++;
}