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


C++ deQueue函数代码示例

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


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


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