本文整理汇总了C++中QueueEmpty函数的典型用法代码示例。如果您正苦于以下问题:C++ QueueEmpty函数的具体用法?C++ QueueEmpty怎么用?C++ QueueEmpty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QueueEmpty函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: hwRemove
VOID hwRemove(MINIPORT_ADAPTER *Adapter)
{
PBUFFER_DESCRIPTOR dsc;
ENTER;
//sangam :Free the pending data packets and control packets
while(!QueueEmpty(Adapter->hw.Q_Send.Head)) { //sangam dbg : used only for data packet so free skb
DumpDebug(DISPATCH, "<1> Freeing Q_Send");
dsc = (PBUFFER_DESCRIPTOR) QueueGetHead(Adapter->hw.Q_Send.Head);
if (!dsc) {
DumpDebug(DISPATCH, "<1> Fail...node is null");
continue;
}
QueueRemoveHead(Adapter->hw.Q_Send.Head);
if(dsc->Buffer)
kfree(dsc->Buffer);
if(dsc)
kfree(dsc);
}
// stop data out buffer
// if (Adapter->hw.ReceiveBuffer!= NULL)
// kfree(Adapter->hw.ReceiveBuffer);
// stop TempData out buffer
#if 0 //cky 20100624
if (Adapter->hw.ReceiveTempBuffer!= NULL)
kfree(Adapter->hw.ReceiveTempBuffer);
#endif
hwGPIODeInit();
LEAVE;
}
开发者ID:Silvist,项目名称:kernel-R910,代码行数:31,代码来源:hardware.c
示例2: BFSTraverse
void BFSTraverse(ALGraph G,void(*Visit)(char*))
{/*按广度优先非递归遍历图G。使用辅助队列Q和访问标志数组visited。*/
int v,u,w;
VertexType u1,w1;
LinkQueue Q;
for(v=0;v<G.vexnum;++v)
visited[v]=FALSE; /* 置初值 */
InitQueue(&Q); /* 置空的辅助队列Q */
for(v=0;v<G.vexnum;v++) /* 如果是连通图,只v=0就遍历全图 */
if(!visited[v]) /* v尚未访问 */
{
visited[v]=TRUE;
Visit(G.vertices[v].data);
EnQueue(&Q,v); /* v入队列 */
while(!QueueEmpty(Q)) /* 队列不空 */
{
DeQueue(&Q,&u); /* 队头元素出队并置为u */
strcpy(u1,*GetVex(G,u));
for(w=FirstAdjVex(G,u1);w>=0;w=NextAdjVex(G,u1,strcpy(w1,*GetVex(G,w))))
if(!visited[w]) /* w为u的尚未访问的邻接顶点 */
{
visited[w]=TRUE;
Visit(G.vertices[w].data);
EnQueue(&Q,w); /* w入队 */
}
}
}
printf("\n");
}
开发者ID:Jzhi,项目名称:C-repository,代码行数:29,代码来源:1-107.c
示例3: BFSTraverse
/**
* 算法7.6,按广度优先非递归遍历图G,使用辅助队列Q和访问标志数组visited
*/
void BFSTraverse(ALGraph G, Boolean visited[], Status (*Visit)(ALGraph G, int v))
{
int u, v, w;
LinkQueue Q;
InitQueue(Q);
for (v = 0; v < G.vexnum; v++) {
visited[v] = false;
}
for (v = 0; v < G.vexnum; v++) {
if (!visited[v]) {
visited[v] = true;
Visit(G, v);
EnQueue(Q, v);
while (!QueueEmpty(Q)) {
DeQueue(Q, u); //附着元素出列并置为u
for (w = FirstAdjVex(G, u); w >= 0; w = NextAdjVex(G, u, w)) {
if (!visited[w]) {
visited[w] = true;
Visit(G, w);
EnQueue(Q, w);
}
}
}
}
}
}
开发者ID:Annie2333,项目名称:DS_Code,代码行数:31,代码来源:DFS_BFS.cpp
示例4: Parent
TElemType Parent(CSTree T,TElemType cur_e)
{ /* 初始条件: 树T存在,cur_e是T中某个结点 */
/* 操作结果: 若cur_e是T的非根结点,则返回它的双亲,否则函数值为"空" */
CSTree p,t;
LinkQueue q;
InitQueue(&q);
if(T) /* 树非空 */
{
if(Value(T)==cur_e) /* 根结点值为cur_e */
return Nil;
EnQueue(&q,T); /* 根结点入队 */
while(!QueueEmpty(q))
{
DeQueue(&q,&p);
if(p->firstchild) /* p有长子 */
{
if(p->firstchild->data==cur_e) /* 长子为cur_e */
return Value(p); /* 返回双亲 */
t=p; /* 双亲指针赋给t */
p=p->firstchild; /* p指向长子 */
EnQueue(&q,p); /* 入队长子 */
while(p->nextsibling) /* 有下一个兄弟 */
{
p=p->nextsibling; /* p指向下一个兄弟 */
if(Value(p)==cur_e) /* 下一个兄弟为cur_e */
return Value(t); /* 返回双亲 */
EnQueue(&q,p); /* 入队下一个兄弟 */
}
}
}
}
return Nil; /* 树空或没找到cur_e */
}
开发者ID:githubzenganiu,项目名称:toekn,代码行数:33,代码来源:1-71.c
示例5: QueueGet
DWORD QueueGet (QUEUE_OBJECT *q, PVOID msg, DWORD msize, DWORD MaxWait)
{
DWORD TotalWaitTime = 0;
BOOL TimedOut = FALSE;
WaitForSingleObject (q->qGuard, INFINITE);
if (q->msgArray == NULL) return 1; /* Queue has been destroyed */
while (QueueEmpty (q) && !TimedOut)
{
ReleaseMutex (q->qGuard);
WaitForSingleObject (q->qNe, CV_TIMEOUT);
if (MaxWait != INFINITE)
{
TotalWaitTime += CV_TIMEOUT;
TimedOut = (TotalWaitTime > MaxWait);
}
WaitForSingleObject (q->qGuard, INFINITE);
}
/* remove the message from the queue */
if (!TimedOut) QueueRemove (q, msg, msize);
/* Signal that the queue is not full as we've removed a message */
PulseEvent (q->qNf);
ReleaseMutex (q->qGuard);
return TimedOut ? WAIT_TIMEOUT : 0;
}
开发者ID:jiangguang5201314,项目名称:ZNginx,代码行数:27,代码来源:QueueObj_noSOAW.c
示例6: BFSTraverse
void BFSTraverse(MGraph G)
{
int i,j;
Queue Q;
for(i=0; i<G.numVertexes; i++)
visited[i]=FALSE;
InitQueue(&Q);
for(i=0; i<G.numVertexes; ++i)
{
if(!visited[i])
{
visited[i]=TRUE;
printf("%c ",G.vexs[i]);
EnQueue(&Q,i);
while(!QueueEmpty(Q))
{
DeQueue(&Q,&i);
for(j=0; j<G.numVertexes; j++)
{
if(G.arc[i][j]==1 && !visited[j])
{
visited[j]=TRUE;
printf("%c ",G.vexs[j]);
EnQueue(&Q,j);
}
}
}
}
}
}
开发者ID:heyuanchuan,项目名称:Data_Structures_C,代码行数:30,代码来源:chapter_5_Breadth_First_Search.cpp
示例7: BFSTraverse
void BFSTraverse(AMLGraph G,Status(*Visit)(VertexType))
{ /* 初始条件: 图G存在,Visit是顶点的应用函数。*/
/* 操作结果: 从第1个顶点起,按广度优先非递归遍历图G,并对每个顶点调用函数 */
/* Visit一次且仅一次。一旦Visit()失败,则操作失败。 */
/* 使用辅助队列Q和访问标志数组visite */
int v,u,w;
VertexType w1,u1;
LinkQueue Q;
for(v=0;v<G.vexnum;v++)
visite[v]=FALSE; /* 置初值 */
InitQueue(&Q); /* 置空的辅助队列Q */
for(v=0;v<G.vexnum;v++)
if(!visite[v]) /* v尚未访问 */
{
visite[v]=TRUE; /* 设置访问标志为TRUE(已访问) */
Visit(G.adjmulist[v].data);
EnQueue(&Q,v); /* v入队列 */
while(!QueueEmpty(Q)) /* 队列不空 */
{
DeQueue(&Q,&u); /* 队头元素出队并置为u */
strcpy(u1,*GetVex(G,u));
for(w=FirstAdjVex(G,u1);w>=0;w=NextAdjVex(G,u1,strcpy(w1,*GetVex(G,w))))
if(!visite[w]) /* w为u的尚未访问的邻接顶点的序号 */
{
visite[w]=TRUE;
Visit(G.adjmulist[w].data);
EnQueue(&Q,w);
}
}
}
printf("\n");
}
开发者ID:githubzenganiu,项目名称:toekn,代码行数:32,代码来源:1-105.c
示例8: BFSTraverse
/* 邻接矩阵的广度遍历算法 */
void BFSTraverse(MGraph G)
{
int i, j;
Queue Q;
for(i = 0; i < G.numVertexes; i++)
visited[i] = FALSE;
InitQueue(&Q); /* 初始化一辅助用的队列 */
for(i = 0; i < G.numVertexes; i++) /* 对每一个顶点做循环 */
{
if (!visited[i]) /* 若是未访问过就处理 */
{
visited[i]=TRUE; /* 设置当前顶点访问过 */
printf("%c ", G.vexs[i]);/* 打印顶点,也可以其它操作 */
EnQueue(&Q,i); /* 将此顶点入队列 */
while(!QueueEmpty(Q)) /* 若当前队列不为空 */
{
DeQueue(&Q,&i); /* 将队对元素出队列,赋值给i */
for(j=0;j<G.numVertexes;j++)
{
/* 判断其它顶点若与当前顶点存在边且未访问过 */
if(G.arc[i][j] == 1 && !visited[j])
{
visited[j]=TRUE; /* 将找到的此顶点标记为已访问 */
printf("%c ", G.vexs[j]); /* 打印顶点 */
EnQueue(&Q,j); /* 将找到的此顶点入队列 */
}
}
}
}
}
}
开发者ID:CatcherX,项目名称:DataStructure,代码行数:32,代码来源:03邻接矩阵深度和广度遍历DFS_BFS.c
示例9: Parent
TElemType Parent(BiTree T,TElemType e)
{ // 初始条件: 二叉树T存在,e是T中某个结点
// 操作结果: 若e是T的非根结点,则返回它的双亲,否则返回"空"
LinkQueue q;
QElemType a;
if(T) // 非空树
{
InitQueue(q); // 初始化队列
EnQueue(q,T); // 树根入队
while(!QueueEmpty(q)) // 队不空
{
DeQueue(q,a); // 出队,队列元素赋给a
if(a->lchild&&a->lchild->data==e||a->rchild&&a->rchild->data==e) // 找到e(是其左或右孩子)
return a->data; // 返回e的双亲的值
else // 没找到e,则入队其左右孩子指针(如果非空)
{
if(a->lchild)
EnQueue(q,a->lchild);
if(a->rchild)
EnQueue(q,a->rchild);
}
}
}
return Nil; // 树空或没找到e
}
开发者ID:wuzongbin2008,项目名称:c_test,代码行数:25,代码来源:bo6-2.CPP
示例10: Parent
TElemType Parent(CSTree T, TElemType cur_e)
{
CSTree p, t;
LinkQueue q;
InitQueue(q);
if (T) {
if (Value(T) == cur_e)
return Nil;
EnQueue(q, T);
while (!QueueEmpty(q)) {
DeQueue(q, p);
if (p->firstchild) {
if (p->firstchild->data == cur_e)
return Value(p);
t = p;
p = p->firstchild;
EnQueue(q, p);
while (p->nextsibling) {
p = p->nextsibling;
if (Value(p) == cur_e)
return Value(t);
EnQueue(q, p);
}
}
}
}
return Nil;
}
开发者ID:zqw86713,项目名称:Data.Structure.Solution,代码行数:29,代码来源:bo6-5.cpp
示例11: LevelOrderTraverse
void LevelOrderTraverse(CSTree T, void (*Visit)(TElemType))
{
CSTree p;
LinkQueue q;
InitQueue(q);
if (T) {
Visit(Value(T));
EnQueue(q, T);
while (!QueueEmpty(q)) {
DeQueue(q, p);
if (p->firstchild) {
p = p->firstchild;
Visit(Value(p));
EnQueue(q, p);
while (p->nextsibling) {
p = p->nextsibling;
Visit(Value(p));
EnQueue(q, p);
}
}
}
}
printf("\n");
}
开发者ID:zqw86713,项目名称:Data.Structure.Solution,代码行数:25,代码来源:bo6-5.cpp
示例12: LevelOrderTraverse
void LevelOrderTraverse(CSTree T,void(*Visit)(TElemType))
{ /* 层序遍历孩子-兄弟二叉链表结构的树T */
CSTree p;
LinkQueue q;
InitQueue(&q);
if(T)
{
Visit(Value(T)); /* 先访问根结点 */
EnQueue(&q,T); /* 入队根结点的指针 */
while(!QueueEmpty(q)) /* 队不空 */
{
DeQueue(&q,&p); /* 出队一个结点的指针 */
if(p->firstchild) /* 有长子 */
{
p=p->firstchild;
Visit(Value(p)); /* 访问长子结点 */
EnQueue(&q,p); /* 入队长子结点的指针 */
while(p->nextsibling) /* 有下一个兄弟 */
{
p=p->nextsibling;
Visit(Value(p)); /* 访问下一个兄弟 */
EnQueue(&q,p); /* 入队兄弟结点的指针 */
}
}
}
}
}
开发者ID:githubzenganiu,项目名称:toekn,代码行数:27,代码来源:1-71.c
示例13: BFSTraverse
Status BFSTraverse(MGraph G,Status(*Visit)(int v))
{
Queue q;
QElemType e;
int i,j;
for(i=0; i<G.vexnum; i++)
Visited[i]=FALSE;
if(!InitQueue(q))return ERROR;
EnQueue(q,G.vexs[0]);//将第一个顶点入队
Visited[0]=TRUE;
printf("广度优先遍历:");
while(!QueueEmpty(q))
{
GetHead(q,e);
i=LocateVex(G,e);
for(j=0; j<G.vexnum; j++)
if(G.arcs[i][j].adj!=0)
if(!Visited[j])
{
Visited[j]=TRUE;
EnQueue(q,G.vexs[j]);
}
DeQueue(q,e);
Visit(e);
}
printf("\n");
return OK;
}
开发者ID:geroge-gao,项目名称:DataStructure,代码行数:31,代码来源:BFS.cpp
示例14: DMP_INLINE
DMP_INLINE(void) can_RoundRobin(CAN_Bus *can)
{
CANFrame temp;
if (QueueEmpty(can->xmit))
return;
io_DisableINT();
if (!(io_In32(can->ioHandle, can->REQ) & (0x01L << (can->round*2))))
{
PopBufQueue(can->xmit, (void*)&temp);
io_Out32(can->ioHandle, can->TX[can->round].TYPE , (unsigned long)temp.type | ((unsigned long)temp.length << 4));
io_Out32(can->ioHandle, can->TX[can->round].IDR , temp.identifier);
io_Out32(can->ioHandle, can->TX[can->round].DATAL, temp.Data.dword[0]);
io_Out32(can->ioHandle, can->TX[can->round].DATAH, temp.Data.dword[1]);
io_Out32(can->ioHandle, can->REQ, io_In32(can->ioHandle, can->REQ) | (0x01UL << (can->round*2)));
can->round++;
if (can->round == 3)
can->round = 0;
}
io_RestoreINT();
}
开发者ID:brucetsao,项目名称:Print3D,代码行数:25,代码来源:can.cpp
示例15: GetHead
Status GetHead(const SqQueue &Q, QElemType &e)
{
if(QueueEmpty(Q)) return ERROR;
e = Q.base[Q.front];
return OK;
}
开发者ID:jinhaoxia,项目名称:hdu-data-structure-course,代码行数:7,代码来源:SqQueue.cpp
示例16: BFSTraverse
void BFSTraverse(MGraph G, Status(*Visit)(VertexType))
{/* 初始条件: 图G存在,Visit是顶点的应用函数。算法7.6 */
/* 操作结果: 从第1个顶点起,按广度优先非递归遍历图G,并对每个顶点调用函数 */
/* Visit一次且仅一次。一旦Visit()失败,则操作失败。 */
/* 使用辅助队列Q和访问标志数组visited */
int u, v, w;
VertexType w1, u1;
SqQueue Q;
for (v = 0; v < G.vexnum; v++)
visited[v] = FALSE; //访问标志数组初始化(未被访问)
InitQueue(Q);
for (v = 0; v < G.vexnum; v++) {
if (!visited[v]) {
visited[v] = TRUE;
Visit(G.vexs[v]);
EnQueue(Q, v);
while (!QueueEmpty(Q)) {
DeQueue(Q, u); //队头元素出队并置为u
strcpy(u1, GetVex(G, u));
for (w = FirstAdjVex(G, u1); w != -1; w = NextAdjVex(G, u1, strcpy(w1, GetVex(G, w))))
if (!visited[w]) { // w为u的尚未访问的邻接顶点的序号
visited[w] = TRUE;
Visit(G.vexs[w]);
EnQueue(Q, w);
}
}
}
}
}
开发者ID:ericsahit,项目名称:myproject,代码行数:29,代码来源:MGraph.cpp
示例17: main
void main()
{
Person dancer[MAXSIZE];
int number;
int i;
Person p;
SqQueue Mdancers,Fdancers;
InitQueue(Mdancers);
InitQueue(Fdancers);
printf("请输入跳舞的人数:");
scanf("%d",&number);
for(i=0;i<number;i++)
{
p=dancer[i];
printf("请输入第%d位舞者的姓名:",i+1);
scanf("%s",p.name );
printf("请确认舞者的性别(0.女1.男):");
scanf("%d",&p.sex );
if(p.sex==0)
EnQueue(Fdancers,p);
else
EnQueue(Mdancers,p);
}
printf("the dancing persons are:\n");
while (QueueEmpty(Fdancers)&&QueueEmpty(Mdancers))
{
DeQueue(Fdancers,p);
printf("%s\n",p.name);
DeQueue(Mdancers,p);
printf("%s\n",p.name);
printf("\n");
}
if(QueueEmpty(Fdancers))
{
p=GetHead(Fdancers);
printf("next danse,the first woman to get the partner is:%s",p.name);
}
else if(QueueEmpty(Mdancers))
{
p=GetHead(Mdancers);
printf("next danse,the first man to get the partner is:%s",p.name);
}
else
printf("匹配恰好完成!");
}
开发者ID:HannibalWangLecter,项目名称:Homework,代码行数:47,代码来源:QueueTestApp.cpp
示例18: ComRxWait
BOOL COMMAPI ComRxWait(HCOMM hc, DWORD dwTimeOut)
{
if (!hc)
return FALSE;
if (dwTimeOut == -1)
{
while(!ComIsOnline(hc))
sleep(0);
}
else
{
/* comisonline takes about 250 ms to run */
while (!ComIsOnline(hc) && dwTimeOut)
{
sleep(0);
if (dwTimeOut > 275)
dwTimeOut -= 275;
else
dwTimeOut = 0;
}
}
#if 0 /* not yet */
/* I think this is sort of like select(), but I'm handling that right
* against read() to avoid wierd-assed blocking problems.
*/
DWORD rc;
/* Set the event mask so that we watch for incoming characters */
ResetEvent(hc->hevRxWait);
SetCommMask(hc->h, DEFAULT_COMM_MASK | EV_RXCHAR);
/* Wait for something to happen */
if (QueueEmpty(&hc->cqRx))
{
#ifdef DEBUG_PIPE
PDPrintf("rx: wait\n");
#endif
rc=WaitForSingleObject(hc->hevRxWait,
dwTimeOut==-1 ? INFINITE : dwTimeOut);
#ifdef DEBUG_PIPE
PDPrintf("rx: end wait\n");
#endif
}
/* Disable received-character events */
SetCommMask(hc->h, DEFAULT_COMM_MASK);
return (rc != WAIT_TIMEOUT);
#else /* not yet */
SetCommMask(hc->h, DEFAULT_COMM_MASK | EV_RXCHAR);
return TRUE;
#endif
}
开发者ID:klamonte,项目名称:maximus,代码行数:59,代码来源:fdcomm.c
示例19: GetHeadQueue
/*
* @description:返回队头元素
*/
Status GetHeadQueue(LinkQueue Q,QElemType *elem) {
if(QueueEmpty(Q))
return ERROR;
(*elem) = Q.font->data;
return OK;
}
开发者ID:doodlesomething,项目名称:doodlesomething,代码行数:11,代码来源:LinkQueue.c
示例20: ProcessSchedule
//----------------------------------------------------------------------
//
// ProcessSchedule
//
// Schedule the next process to run. If there are no processes to
// run, exit. This means that there should be an idle loop process
// if you want to allow the system to "run" when there's no real
// work to be done.
//
// NOTE: the scheduler should only be called from a trap or interrupt
// handler. This way, interrupts are disabled. Also, it must be
// called consistently, and because it might be called from an interrupt
// handler (the timer interrupt), it must ALWAYS be called from a trap
// or interrupt handler.
//
// Note that this procedure doesn't actually START the next process.
// It only changes the currentPCB and other variables so the next
// return from interrupt will restore a different context from that
// which was saved.
//
//----------------------------------------------------------------------
void
ProcessSchedule ()
{
PCB *pcb;
int i;
dbprintf ('p', "Now entering ProcessSchedule (cur=0x%x, %d ready)\n",
currentPCB, QueueLength (&runQueue));
// The OS exits if there's no runnable process. This is a feature, not a
// bug. An easy solution to allowing no runnable "user" processes is to
// have an "idle" process that's simply an infinite loop.
if (QueueEmpty (&runQueue)) {
printf ("No runnable processes - exiting!\n");
exitsim (); // NEVER RETURNS
}
// Move the front of the queue to the end, if it is the running process.
pcb = (PCB *)((QueueFirst (&runQueue))->object);
if (pcb == currentPCB)
{
QueueRemove (&pcb->l);
QueueInsertLast (&runQueue, &pcb->l);
}
// Now, run the one at the head of the queue.
pcb = (PCB *)((QueueFirst (&runQueue))->object);
currentPCB = pcb;
dbprintf ('p',"About to switch to PCB 0x%x,flags=0x%x @ 0x%x\n",
pcb, pcb->flags,
pcb->sysStackPtr[PROCESS_STACK_IAR]);
// Clean up zombie processes here. This is done at interrupt time
// because it can't be done while the process might still be running
while (!QueueEmpty (&zombieQueue)) {
pcb = (PCB *)(QueueFirst (&zombieQueue)->object);
dbprintf ('p', "Freeing zombie PCB 0x%x.\n", pcb);
QueueRemove (&pcb->l);
ProcessFreeResources (pcb);
}
// Set the timer so this process gets at most a fixed quantum of time.
TimerSet (processQuantum);
dbprintf ('p', "Leaving ProcessSchedule (cur=0x%x)\n", currentPCB);
}
开发者ID:RachanaRajSunku,项目名称:Memory-Management-in-DLXOS,代码行数:65,代码来源:process.c
注:本文中的QueueEmpty函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论