• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ deQueue函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: checkStackPairwiseOrder

int checkStackPairwiseOrder(struct sNode *top) {
    struct Queue *q = createQueue();
    struct sNode *s = top;
    
    int pairwiseOrdered = 1;

    while (!isEmpty(s))
        enQueue(q, pop(&s));

    while (!queueIsEmpty(q))
        push(&s, deQueue(q)->key);

    while (!isEmpty(s)) {
        int n = pop(&s);
        enQueue(q, n);
        if (!isEmpty(s)) {
            int m  = pop(&s);
            enQueue(q, m);
            if(abs(n - m) != 1) {
                pairwiseOrdered = 0;
            }    
        }
    }    

    while (!queueIsEmpty(q))
        push(&s, deQueue(q)->key);
    return pairwiseOrdered;
}        
开发者ID:dataAlgorithms,项目名称:dataStructure,代码行数:28,代码来源:checkStackPairwiseOrder.c


示例2: main

int main(void){
    
    Queue_t *q;
    Stack_t *stack1 = (Stack_t*)malloc(sizeof(Stack_t));
    Stack_t *stack2 = (Stack_t*)malloc(sizeof(Stack_t));
    
    q->basic = stack1;
    q->forDequeue = stack2;
    
    puts("//enqueue");
    enQueue(q, 1);
    enQueue(q, 2);
    enQueue(q, 3);
    
    printQueue(q);
    
    puts("//deQueue");
    deQueue(q);
    deQueue(q);
    printQueue(q);
    
    deQueue(q);
    printQueue(q);
    
    deQueue(q);
    
    
    
    
    return 0;
    
}
开发者ID:Kyoo32,项目名称:NEXT2015-1,代码行数:32,代码来源:queue_by_two_stacks.c


示例3: main

void main(){
	sQueue q;
	init(&q);
	
	enQueue(&q,5);
	deQueue(&q);
	enQueue(&q,71);
	deQueue(&q);
	enQueue(&q,72);
	deQueue(&q);
	enQueue(&q,73);
	enQueue(&q,74);
	deQueue(&q);
	enQueue(&q,75);
	enQueue(&q,76);
	enQueue(&q,77);
	deQueue(&q);
	enQueue(&q,78);
	deQueue(&q);
	deQueue(&q);
	deQueue(&q);
	deQueue(&q);
	deQueue(&q);
	
}
开发者ID:king63499,项目名称:queue,代码行数:25,代码来源:queue.c


示例4: main

int main(void){

	printf("FIFO: First In First Out\n");

	printf("Queue is %s\n", (isEmpty()? "Empty": "Not Empty"));
	printf("Queue Size = %d\n", queueSize());

	enQueue(1);
	enQueue(2);
	enQueue(13);
	enQueue(6);

	printQueue();
	printf("Queue Size = %d\n", queueSize());


	printf("1st DeQueue = 1 || deQueue Result = %d\n", deQueue());
	printf("2nd DeQueue = 2 || deQueue Result = %d\n", deQueue());
	printf("Queue Size = %d\n", queueSize());

	printQueue();

	printf("3rd DeQueue = 13 || deQueue Result = %d\n", deQueue());
	printf("4th DeQueue = 6  || deQueue Result = %d\n", deQueue());

	printf("Add 6 to the queue\n");
	enQueue(6);
	printQueue();

	printf("Queue Size = %d\n", queueSize());
	printf("Queue is %s\n", (isEmpty()? "Empty": "Not Empty"));


	return 0;
}
开发者ID:AbdulmalikGadeer,项目名称:C-Language,代码行数:35,代码来源:Queue.c


示例5: test_inserts_the_element_at_the_starting_of_queue

void test_inserts_the_element_at_the_starting_of_queue(){
	void* pQueue = createPQueue();
	int data = 40;
	ASSERT(1 == enQueue(pQueue, &data, 5));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(0 == deQueue(pQueue));
};
开发者ID:shwetado,项目名称:DSA,代码行数:7,代码来源:pQueueTest.c


示例6: test_inserts_the_element_first_having_higher_priority_float

void test_inserts_the_element_first_having_higher_priority_float(){
	void* pQueue = createPQueue();
	float data1 = 10.0f , data2 = 20.0f;
	ASSERT(1 == enQueue(pQueue, &data2, 2));
	ASSERT(1 == enQueue(pQueue, &data1, 1));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(0 == deQueue(pQueue));
};
开发者ID:shwetado,项目名称:DSA,代码行数:9,代码来源:pQueueTest.c


示例7: test_inserts_the_element_first_having_lower_priority_double

void test_inserts_the_element_first_having_lower_priority_double(){
	void* pQueue = createPQueue();
	double data1 = 10.0 , data2 = 20.0;
	ASSERT(1 == enQueue(pQueue, &data1, 1));
	ASSERT(1 == enQueue(pQueue, &data2, 2));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(0 == deQueue(pQueue));
};
开发者ID:shwetado,项目名称:DSA,代码行数:9,代码来源:pQueueTest.c


示例8: test_inserts_the_element_first_having_lower_priority_char

void test_inserts_the_element_first_having_lower_priority_char(){
	void* pQueue = createPQueue();
	char data1 = 'a' , data2 = 'b';
	ASSERT(1 == enQueue(pQueue, &data1, 1));
	ASSERT(1 == enQueue(pQueue, &data2, 2));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(0 == deQueue(pQueue));
};
开发者ID:shwetado,项目名称:DSA,代码行数:9,代码来源:pQueueTest.c


示例9: test_inserts_the_element_first_having_higher_priority_String

void test_inserts_the_element_first_having_higher_priority_String(){
	void* pQueue = createPQueue();
	String data1 = "a" , data2 = "b";
	ASSERT(1 == enQueue(pQueue, &data2, 2));
	ASSERT(1 == enQueue(pQueue, &data1, 1));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(1 == deQueue(pQueue));
	ASSERT(0 == deQueue(pQueue));
};
开发者ID:shwetado,项目名称:DSA,代码行数:9,代码来源:pQueueTest.c


示例10: test_to_dequeue_an_int_element

void test_to_dequeue_an_int_element(){
	int element = 4;
	queue = create(sizeof(int), 3);
	ASSERT(enQueue(queue, &element));
	ASSERT(enQueue(queue, &element));
	deQueue(queue);
	deQueue(queue);
	ASSERT(1==queue->queueInfo.front);
}
开发者ID:jainsahab,项目名称:circularQueue,代码行数:9,代码来源:queueLibTest.c


示例11: test_to_check_behaviour_when_deleting_all_elements

void test_to_check_behaviour_when_deleting_all_elements(){
	char exp_arr[] = {'a','b'};
	CircularQueue expected = {exp_arr,-1,-1,2,sizeof(char)};
	CircularQueue* actual = create(sizeof(char),2);
	char element1 = 'a';
	char element2 = 'b';
	char* firstElement;
	int res;
	res = enQueue(actual,&element1);
	res = enQueue(actual,&element2);
	firstElement = deQueue(actual);
	firstElement = deQueue(actual);
	ASSERT(compareQueue(actual,&expected));
};
开发者ID:pallavig,项目名称:dsa,代码行数:14,代码来源:circularQueueTest.c


示例12: main

int main()
{
    struct Queue *q = createQueue();
    enQueue(q, 10);
    enQueue(q, 20);
    deQueue(q);
    deQueue(q);
    enQueue(q, 30);
    enQueue(q, 40);
    enQueue(q, 50);
    struct QNode *n = deQueue(q);
    if (n != NULL)
        printf("Dequeued item is %d", n->key);
    return 0;
}
开发者ID:Sailja,项目名称:Queue,代码行数:15,代码来源:LinkedListimplementation.c


示例13: main

int main(int argc, char const *argv[])
{
	Queue* queue = initQueue();
	bool empty = isEmpty(queue);
	if (empty)
		printf("queue is empty\n");
	else
		printf("queue is not empty, error\n");
	bool success = enQueue(queue, &arr[0]);
	if (success)
		printf("enQueue success\n");
	else
		printf("enQueue failed, error\n");
	int* ele;
	success = deQueue(queue, &ele);
	if (success)
		printf("%d, deQueue success", *ele);
	else
		printf("error\n");
	printf("isEmpty: %d\n", isEmpty(queue));
	printf("queueSize: %d\n", queueSize(queue));
	enQueue(queue, &arr[1]);
	enQueue(queue, &arr[2]);
	enQueue(queue, &arr[3]);
	enQueue(queue, &arr[4]);
	enQueue(queue, &arr[5]);
	enQueue(queue, &arr[6]);
	enQueue(queue, &arr[7]);
	enQueue(queue, &arr[8]);
	printf("isEmpty: %d\n", isEmpty(queue));
	printf("queueSize: %d\n", queueSize(queue));
	success = deQueue(queue, &ele);
	if (success)
		printf("%d, deQueue success\n", *ele);
	else
		printf("deQueue error\n");

	int count = 105;
	while (count > 0) {
		if (enQueue(queue, &arr[9]))
			--count;
		else
			break;
	}
	printf("count: %d\n", count);
	printf("queueSize: %d\n", queueSize(queue));
	return 0;
}
开发者ID:clearlylin,项目名称:Algorithm,代码行数:48,代码来源:queueTest.c


示例14: test_to_dequeue_an_int_element_when_it_is_already_empty

void test_to_dequeue_an_int_element_when_it_is_already_empty(){
	void *dequeuedElement;
	Queue* queue = create(sizeof(int), 3);
	dequeuedElement = deQueue(queue); 
	free(queue->base);
	free(queue);	
}
开发者ID:jainsahab,项目名称:DSA,代码行数:7,代码来源:queueLibTest.c


示例15: isBipartite

bool isBipartite(int G[][V], int src)
{
    int colorMatrix[V], color, temp, u;

    initColorMatrix(colorMatrix, V);

    struct Queue* queue = createQueue(V);

    color = 1;
    colorMatrix[src] = color;
    enQueue(queue, src);

    while (!isEmpty(queue))
    {
        temp = deQueue(queue);
        // assign alternate color to its neighbor
        color = 1 - colorMatrix[temp];

    	for (u = 0; u < V; ++u)
        {
        	// an edge exists and destination not colored
        	if (G[temp][u] && colorMatrix[u] == -1)
	        {
		        colorMatrix[u] = color;
                enQueue(queue, u);
	        }

            else if (G[temp][u] && colorMatrix[u] == colorMatrix[temp])
                return false;
        }
    }

    return true;
}
开发者ID:hermesdragon,项目名称:CODING,代码行数:34,代码来源:bp2.c


示例16: isPathBfs

int isPathBfs(Graph g, Vertex v, Vertex w)
{
	int isPath = FALSE;
	Queue q = newQueue(); // create a new queue
	Vertex curV = 0;
	int *visited = calloc(g->nV, sizeof(int)); // allocate + init to 0
	int i = 0;

	assert(visited != NULL);
	enQueue(q, v);
	visited[v] = TRUE;

	while ( !isEmptyQueue(q) ){ // still have vertices to traverse
		curV = deQueue(q); // get a vertex from the queue
		printf("Visiting: %d.\n", curV);
		visited[curV] = TRUE; // mark it as visited
		if (curV == w) { isPath = TRUE; } 
		for (i = 0; i < g->nV; i++){ // find vertices to add to queue
			if (g->edges[curV][i] && !visited[i]){ // found a vertex to add
				enQueue(q, i); // add it to queue
				visited[i] = TRUE; // mark it as visited
			}
		}
	}	
	free(visited);
	deleteQueue(q);
	return isPath;
}
开发者ID:matthewT53,项目名称:Data-structures-and-algorithms,代码行数:28,代码来源:graph.c


示例17: deQueue

/****从队列中取出请求
*主队列,副队列交换了
*
**/
struct req_t* Queue::doRequest()
{
   struct req_t *req =NULL;
   //先从主队列中取
    deQueue(m_pLink,req); //它看到的永远是主队列
    return req;
}
开发者ID:yushiyaogg,项目名称:backup,代码行数:11,代码来源:Queue.cpp


示例18: main

int main()
{
	int num, data, e;

	while(1)
	{
		system("cls"); //system clear
		printf("\n ## 큐구현: 링크드큐## \n\n");
		printf("1) 데이터삽입: enQueue \n");
		printf("2) 데이터삭제: deQueue \n");
		printf("3) 전체출력\n");
		printf("4) 프로그램종료\n\n");
		printf("메뉴선택: ");
		scanf("%d", &num);	
			
		switch(num) {
		case 1 : printf("\n 삽입할데이터입력: ");
		scanf("%d", &data); fflush(stdin); //delete memory garbage 
		enQueue(data);
		break;
		
		case 2 : deQueue(); break;
		
		case 3 : queue_Print(); break;
		
		case 4 : printf("프로그램종료... \n"); return 0;
		
		default : printf("잘못선택하셨습니다. \n"); fflush(stdin);
		} system("pause");
	} //while
} //main
开发者ID:ChiHyeonKim,项目名称:DataStructure,代码行数:31,代码来源:Linked_queue.cpp


示例19: scheduler

// **********************************************************************
// **********************************************************************
// scheduler
//
static int scheduler()
{
	int nextTask;
	// ?? Design and implement a scheduler that will select the next highest
	// ?? priority ready task to pass to the system dispatcher.

	// ?? WARNING: You must NEVER call swapTask() from within this function
	// ?? or any function that it calls.  This is because swapping is
	// ?? handled entirely in the swapTask function, which, in turn, may
	// ?? call this function.  (ie. You would create an infinite loop.)

	// ?? Implement a round-robin, preemptive, prioritized scheduler.

	// ?? This code is simply a round-robin scheduler and is just to get
	// ?? you thinking about scheduling.  You must implement code to handle
	// ?? priorities, clean up dead tasks, and handle semaphores appropriately.

	// schedule next task

	nextTask = deQueue(&readyQueue,-1);
	if(nextTask >= 0){
		enQueue(&readyQueue, nextTask, tcb[nextTask].priority);
	}
	if (tcb[nextTask].signal & mySIGSTOP) return -1;

	return nextTask;
} // end scheduler
开发者ID:mukk88,项目名称:cs345,代码行数:31,代码来源:os345.c


示例20: deQueue

// dequeue an item from queue
int deQueue(struct queue *q)
{
    int x, res;

    // both stacks are empty then error
    if (q->stack1 == NULL)
    {
        printf("Q is empty");
        exit(0);
    }
    else if (q->stack1->next == NULL)
    {
        return pop(&q->stack1);
    }
    else
    {
        // pop an item from the stack1
        x = pop(&q->stack1);

        // store the last dequeued item
        res = deQueue(q);

        // push everything back to stack1
        push(&q->stack1, x);
        return res;
    }
}
开发者ID:dataAlgorithms,项目名称:dataStructure,代码行数:28,代码来源:queueUsingTwoStacks.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ deSerializeString函数代码示例发布时间:2022-05-30
下一篇:
C++ de600_put_command函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap