当前位置: 首页>>代码示例>>C++>>正文


C++ CreateQueue函数代码示例

本文整理汇总了C++中CreateQueue函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateQueue函数的具体用法?C++ CreateQueue怎么用?C++ CreateQueue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CreateQueue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	Queue TestQueue = CreateQueue(10);
	cout << "Begin test of queue " << endl;
	for (int i = 0, n = 1; i < 10; i++, n *= 2)
	{
		cout << i + 1 << "> Enqueue : " << n<<endl;
		Enqueue(n, TestQueue);
	}
	PrintQueue(TestQueue);
	cout << "Is Full ? " << IsFull(TestQueue)<<endl;

	for (int i = 0; i < 5; i++)
	{
		cout << i + 1 << " >Dequeue :" << Front(TestQueue) << endl;
		Dequeue(TestQueue);
	}
	PrintQueue(TestQueue);
	cout << "Front and dequeue: " << FrontAndDequeue(TestQueue)<<endl;
	cout << "Now add more data to test the cicular array..." << endl;
	for (int i = 0; i < 5; i++)
	{
		cout << i + 1 << "> Enqueue : " << i << endl;
		Enqueue(i, TestQueue);
	}
	PrintQueue(TestQueue);
	cout << "Now make the queue empty...";
	MakeEmpty(TestQueue);
	cout << "Is Empty ? "<<IsEmpty(TestQueue)<<endl;
	cout << "Now dipose the queue!" << endl;
	DisposeQueue(TestQueue);
	cout << "Test Succeed!" << endl << "Good bye!"<<endl;
	getchar();
}
开发者ID:oceanjaya,项目名称:DataStructurePractice,代码行数:34,代码来源:Test.cpp

示例2: BFSTraversal

int BFSTraversal(GNode* graphRoot,int u,int v){

QNode* queue=CreateQueue(graphRoot->count);

EnQueue(queue,u);

int data;
ALNode* tmpNode;
while(!IsEmptyQueue(queue)){

data=DeQueue(queue);
if(visited[data]==0){
//printf("%d  ",data);
tmpNode=graphRoot->GArray[data]->head;
while(tmpNode){
    if(tmpNode->destination==v){
    return 1;
    }
if(visited[tmpNode->destination]==0){
EnQueue(queue,tmpNode->destination);
}
tmpNode=tmpNode->next;
}
visited[data]=1;
}


}

return 0;
}
开发者ID:sidpka,项目名称:repo,代码行数:31,代码来源:Graph_Connectivity_CheckIfPathExistsBwTwoVertices.C

示例3: main

int main()
{
	FILE *ptr;
	ptr=fopen("file.txt","r");
	CheckFileForError(ptr);
	
  CreateQueue();

  char str[80];
  int i, pnum, atime,btime;
 	while(fgets(str,80,ptr)!=NULL)
 	{
    int *point;

    point = FindNuminString(str,0);
    pnum = *point;
    point = FindNuminString(str,*(point+1));
    atime = *point;
    point = FindNuminString(str,*(point+1));
    btime = *point;
   
   EnQueue(pnum,atime,btime);
  }
  int time_quantum;
  printf("\n Enter the time quantum: ");
  scanf("%d",&time_quantum);
  CalculateRR(time_quantum);


	fclose(ptr);
	DeleteQueue();
	return 0;
}
开发者ID:batraman,项目名称:sandbox,代码行数:33,代码来源:RoundRobin.c

示例4: findBottomLeftValue

int findBottomLeftValue(TreeNode* root) {
    Trique*q=zCreateQueue(1000);;
    Queue*level=CreateQueue(1000);
    zEnqueue(q,root);
    Enqueue(level,0);
    int m=0;
    while(q->NumElements){
        TreeNode *r = zFront(q); 
        zDequeue(q);
        int l = Front(level); 
        Dequeue(level);
        if(r->left) {
            zEnqueue(q,r->left);
            Enqueue(level,l+1);
        }
        if(r->right){
            zEnqueue(q,r->right);
            Enqueue(level,l+1);
        }
        if(l > m){
            m = l;
            root = r;
        }
    }
    return root->val;
}
开发者ID:pocketzeroes,项目名称:proekt,代码行数:26,代码来源:find-bottom-left-tree-value.c

示例5: Bfs

void Bfs(int graph[][maxVertices], int *size, int presentVertex,int *visited)
{
        visited[presentVertex] = 1;
        /* Iterate through all the vertices connected to the presentVertex and perform bfs on those
           vertices if they are not visited before */
        Queue *Q = CreateQueue(maxVertices);
        Enqueue(Q,presentVertex);
        while(Q->size)
        {
                presentVertex = Front(Q);
                printf("Now visiting vertex %d\n",presentVertex);
                Dequeue(Q);
                int iter;
                for(iter=0;iter<size[presentVertex];iter++)
                {
                        if(!visited[graph[presentVertex][iter]])
                        {
                                visited[graph[presentVertex][iter]] = 1;
                                Enqueue(Q,graph[presentVertex][iter]);
                        }
                }
        }
        return;
        

}
开发者ID:gaurav594,项目名称:programs,代码行数:26,代码来源:bfsl.c

示例6: LevelOrderTraversal

void LevelOrderTraversal(struct TNode* root,int n){

if(!root){
return;
}

QNode* queue=CreateQueue(n);
EnQueue(queue,root);

struct TNode* tmpNode;

while(!IsEmptyQueue(queue)){

tmpNode=DeQueue(queue);
if(tmpNode){
printf("%d   ",tmpNode->data);
}
if(tmpNode->left){
EnQueue(queue,tmpNode->left);
}
if(tmpNode->right){
EnQueue(queue,tmpNode->right);
}

}




}
开发者ID:sidpka,项目名称:repo,代码行数:30,代码来源:BT_CompleteBT.C

示例7: bfs_iterative

void bfs_iterative(LGraph graph, Vertex start, void (*func)(nodeptr p))
{
    int visited[graph->vertex_num];
    Queue queue = CreateQueue(graph->vertex_num);
    nodeptr curr;
    curr = graph->G[start];
    visited[curr->adjv] = 1;
    enqueue(queue, curr);
    
    while (!QIsEmpty(queue))
    {        
        while (curr)
        {
            if (visited[curr->adjv] != 1)
            {
                enqueue(queue, curr);
                visited[curr->adjv] = 1;
            }
                
            else
                curr = curr->next;
        }
        nodeptr temp = dequeue(queue);
        curr = graph->G[temp->adjv];
        (*func)(curr);
    }
}
开发者ID:spencerpomme,项目名称:coconuts-on-fire,代码行数:27,代码来源:6-2_bfs_iterative.c

示例8: CheckIfCompleteBinaryTree

int CheckIfCompleteBinaryTree(struct TNode* root,int n){
QNode* queue=CreateQueue(n);
struct TNode* tmpNode;
EnQueue(queue,root);
int result;
while(!IsEmptyQueue(queue)){
tmpNode=DeQueue(queue);

if(IsFullNode(tmpNode)){
    EnQueue(queue,tmpNode->left);
    EnQueue(queue,tmpNode->right);
}else if(tmpNode->right){
result=0;
break;
}else if(tmpNode->left){
continue;
}
else{

while(IsLeafNode(tmpNode) && !IsEmptyQueue(queue)){
tmpNode=DeQueue(queue);
}

if(IsEmptyQueue(queue)){
result=1;
break;
}else{
result=0;
break;
}
}
}
return result;
}
开发者ID:sidpka,项目名称:repo,代码行数:34,代码来源:BT_CompleteBT.C

示例9: main

int main(int argc, char *argv[]){
	int a,cevap;
	struct Queue *q;
	printf("Siradaki eleman sayisi:");
	QueueSize(q);

	if(isEmpty(q)==0){
		printf("Kuyruk bos!");
	}

	if(isFull(q)==0){
		printf("Kuyruk dolu!");
	}

	switch(cevap){
	case 1: printf("1)bos kuyruk yaratmak icin:");
	break;
	case 2: printf("2)Kuyruga kisi eklemek icin");
	break;
	case 3: printf("3)Kuyruktan kisi silmek icin ");
	break;
	default: printf("Hata! 1 2 ya da 3 e basiniz.");
	break;
	}

	if(cevap==1) CreateQueue(q);
	if(cevap==2) Enqueue(q);
	if(cevap==3) Dequeue(q,a);

}
开发者ID:denizsecgin,项目名称:c-projelerim,代码行数:30,代码来源:soru4.c

示例10: ConditionConstructor

//Limit of the queue, and the id of this condition variable{NOT_FULL,NOT_EMPTY}
ConditionPtr ConditionConstructor(int limit, int ID){
	ConditionPtr condition = (ConditionPtr) malloc(sizeof(ConditionStr));
	condition->queue = (Queue)CreateQueue(limit);
	condition->id = ID;
	
	return condition;
}
开发者ID:pasangsherpa,项目名称:scheduler,代码行数:8,代码来源:conditionVar.c

示例11: Queue_is_Empty

void Queue_is_Empty()
{
    Queue Q;
    Q = CreateQueue();
    assert(IsEmpty(Q) == true); 
    DisposeQueue(Q);
}
开发者ID:junhuawa,项目名称:DataStructure,代码行数:7,代码来源:Queue.c

示例12: setup_usart

/* Initialize the USART6. */
void setup_usart(void) {
	USART_InitTypeDef USART_InitStructure;
	GPIO_InitTypeDef GPIO_InitStructure;

	/* Enable the GPIOC peripheral clock. */
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);

	/* Make PC6, PC7 as alternative function of USART6. */
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6);
	GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_USART6);

	/* Initialize PC6, PC7.  */
	GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	GPIO_Init(GPIOC, &GPIO_InitStructure);

	/* Enable the USART6 peripheral clock. */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);

	/* Initialize USART6 with
	 * 115200 buad rate,
	 * 8 data bits,
	 * 1 stop bit,
	 * no parity check,
	 * none flow control.
	 */
	USART_InitStructure.USART_BaudRate = 115200;
	USART_InitStructure.USART_WordLength = USART_WordLength_8b;
	USART_InitStructure.USART_StopBits = USART_StopBits_1;
	USART_InitStructure.USART_Parity = USART_Parity_No;
	USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
	USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
	USART_Init(USART6, &USART_InitStructure);

	/* Enable USART6. */
	USART_Cmd(USART6, ENABLE);

	/* Initial the USART TX streams. */
	for(usart_stream_idx = MAX_USART_STREAM;
		usart_stream_idx > 0;
		usart_stream_idx--)
		ClearStream(usart_stream + usart_stream_idx - 1);
	/* Initial the RX Queue. */
	rxQueue = &__rxQueue;
	CreateQueue(rxQueue, __rxBuf, RX_QUEUELEN, sizeof(uint8_t));
	if(rxQueue != NULL)
		USART_Printf(USART2, "RX pipe created.\r\n");
	else
		USART_Printf(USART2, "RX pipe created failed.\r\n");
	/* Disable RX pipe first. */
	USART_DisableRxPipe(USART6);

	/* Enable USART6 RX interrupt. */
	USART_ITConfig(USART6, USART_IT_RXNE, ENABLE);
	/* Enable USART6 in NVIC vector. */
	NVIC_EnableIRQ(USART6_IRQn);
}
开发者ID:biddyweb,项目名称:MicroHttpServer,代码行数:61,代码来源:usart.c

示例13: main

int main()
{
    CreateQueue();
    CreateMGraph();
    ListComponents();
    return 0;
}
开发者ID:yanxutao,项目名称:DataStructure,代码行数:7,代码来源:061.c

示例14: main

//-----------------------------------------------
// Test a 4-entry queue
//-----------------------------------------------
int main()
{
  int elem = 0;
  queue *Q;
  CreateQueue(Q, 4);
  
  Dequeue(Q);
  Enqueue(Q, ++elem);
  Enqueue(Q, ++elem);
  Enqueue(Q, ++elem);
  Enqueue(Q, ++elem);
  Dequeue(Q);
  Enqueue(Q, ++elem);
  Enqueue(Q, ++elem);
  Dequeue(Q);
  Enqueue(Q, ++elem);
  Dequeue(Q);
  Enqueue(Q, ++elem);
  Dequeue(Q);
  Dequeue(Q);
  Dequeue(Q);
  Dequeue(Q);

  DestroyQueue(Q);

  return 0;
}
开发者ID:jinz2014,项目名称:FP_HLS,代码行数:30,代码来源:test_queue.c

示例15: TEST_F

TEST_F(TQueueTest,  can_detect_when_queue_is_full)
{
  CreateQueue(3);
  SetUpFullQueue();

  ASSERT_TRUE(queue->IsFull());
}
开发者ID:ZhbanovaAnna,项目名称:exa-min-light,代码行数:7,代码来源:test_queue.cpp


注:本文中的CreateQueue函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。