本文整理匯總了C++中Enqueue函數的典型用法代碼示例。如果您正苦於以下問題:C++ Enqueue函數的具體用法?C++ Enqueue怎麽用?C++ Enqueue使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Enqueue函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: AudioSource
void Player::Enqueue (const QStringList& paths, bool sort)
{
QList<AudioSource> parsedSources;
for (const auto& path : paths)
parsedSources << AudioSource (path);
Enqueue (parsedSources, sort);
}
示例2: BasicStatementTask
ACE_Future<QueryResult_AutoPtr> DatabaseWorkerPool::AsyncQuery(const char* sql)
{
QueryResultFuture res;
BasicStatementTask* task = new BasicStatementTask(sql, res);
Enqueue(task);
return res; //! Fool compiler, has no use yet
}
示例3: refer_page
int refer_page (int pagenumber, int hash[], Queue *q)
{
listnode *node = hash[pagenumber];
if (node) {
/* Page was found in the hash. Move the page to the top */
if (q->head == node) {
/* already in front nothing to do */
} else if (q->tail == node) {
/* remove this node from tail and put it in the front */
tail = tail->left;
node->right = q->head;
q->head->left = node;
q->head = node;
} else {
node->left->right = node->right;
node->right->left = node->left;
node->right = q->head;
q->head->left = node;
q->head = node;
}
} else {
node = newlistnode(pagenumber);
Enqueue (node, q);
hash[pagenumber] = node;
}
return 0;
}
示例4: EnqueueString
void EnqueueString(char* X, Queue* Q)
{
/*enqueue elements one by one*/
int i;
for(i=0; X[i]; i++)
Enqueue((unsigned char)X[i], Q);
}
示例5: main
main(int argc, char **argv) {
if (argc < 2) return 0;
int port;
if (sscanf(argv[1], "%d", &port) != 1) return 0;
sockaddr_in serv;
int sd = NewSock();
if (sd < 0 || Bind(sd, port) < 0) return -1;
while(1) {
if (!Ready(sd, -1)) continue;
char mes[516];
sockaddr_in client;
socklen_t c_len = sizeof(client);
int l = recvfrom(sd, mes, 516, 0, (struct sockaddr *)&client, &c_len), stat;
pid_t sub;
while (qn > 0 && (sub = waitpid(-1, &stat, WNOHANG))) Dequeue(sub);
if (Inqueue(client)) {
fprintf(stderr, "get op = %d\n", *(short *)mes);
continue;
}
sub = fork();
if (!sub) {
Serve(mes, client);
_exit(0);
}
Enqueue(client, sub);
}
}
示例6: insert
// Function to insert a new node in complete binary tree
void insert(struct node **root, int data, struct Queue* queue)
{
// Create a new node for given data
struct node *temp = newNode(data);
// If the tree is empty, initialize the root with new node.
if (!*root)
*root = temp;
else
{
// get the front node of the queue.
struct node* front = getFront(queue);
// If the left child of this front node doesn’t exist, set the
// left child as the new node
if (!front->left)
front->left = temp;
// If the right child of this front node doesn’t exist, set the
// right child as the new node
else if (!front->right)
front->right = temp;
// If the front node has both the left child and right child,
// Dequeue() it.
if (hasBothChild(front))
Dequeue(queue);
}
// Enqueue() the new node for later insertions
Enqueue(temp, queue);
}
示例7: UnblockWaiters
static void UnblockWaiters(BuildQueue* queue, NodeState* node)
{
const NodeData *src_node = node->m_MmapData;
int enqueue_count = 0;
for (int32_t link : src_node->m_BackLinks)
{
if (NodeState* waiter = GetStateForNode(queue, link))
{
// Only wake nodes in our current pass
if (waiter->m_MmapData->m_PassIndex != queue->m_CurrentPassIndex)
continue;
// If the node isn't ready, skip it.
if (!AllDependenciesReady(queue, waiter))
continue;
// Did someone else get to the node first?
if (NodeStateIsQueued(waiter) || NodeStateIsActive(waiter))
continue;
//printf("%s is ready to go\n", GetSourceNode(queue, waiter)->m_Annotation);
Enqueue(queue, waiter);
++enqueue_count;
}
}
if (enqueue_count > 0)
WakeWaiters(queue, enqueue_count);
}
示例8: main
/*
* === FUNCTION ======================================================================
* Name: main
* Description:
* =====================================================================================
*/
int
main ( int argc, char *argv[] )
{
int k=0;
Queue my_queue;
Tree_node my_tree_node;
Queue_node dequeue_node;
my_tree_node = malloc ( sizeof(struct tree_node) );
if ( my_tree_node==NULL ) {
fprintf ( stderr, "\ndynamic memory allocation failed\n" );
exit (EXIT_FAILURE);
}
my_tree_node->data='A';
my_tree_node->firstchild=NULL;
my_tree_node->nextsibling = NULL;
my_queue = Init_Queue();
for(k=0;k<7;k++)
{
Enqueue(my_queue, my_tree_node);
my_tree_node->data='A'+k+1;
}
Print_Queue(my_queue);
printf("\n");
while((dequeue_node=Dequeue(my_queue))!=NULL)
{
printf("<!!%c!!>\n",dequeue_node->node_data.data);
free(dequeue_node);
Print_Queue(my_queue);
printf("**************************\n\n");
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
示例9: process
/**
* Main loop for processing segments
* @param ptr useless
*/
static void * process(void * ptr) {
Bucket * b = NULL;
Segment * seg = NULL;
int turn = 0;
while ((seg = (Segment *) Dequeue(service._iq)) != NULL) {
if (seg->unique) {
b = BucketInsert(b, seg);
}
Enqueue(service._oq, seg);
}
if (b != NULL) {
SaveBucket(b);
}
Enqueue(service._oq, NULL);
return NULL;
}
示例10: BasicPQueueTest
void BasicPQueueTest(void)
{
int i;
pqueueADT pq;
printf("\n----------- Testing Basic PQueue functions -----------\n\n");
pq = NewPQueue();
printf("The pqueue was just created. Is it empty? %s", IsEmpty(pq) ? "TRUE" : "FALSE");
for (i = 1; i <= 10; i++)
Enqueue(pq, i);
printf("\nEnqueuing the integers from 1 to 10 (in forward order)\n");
printf("Pqueue should not be empty. Is it empty? %s\n", IsEmpty(pq) ? "TRUE" : "FALSE");
printf("Dequeuing the top 5 elements: ");
for (i = 0; i < 5; i++)
printf("%d ", DequeueMax(pq));
printf("\nDequeuing all the rest: ");
while (!IsEmpty(pq))
printf("%d ", DequeueMax(pq));
printf("\nPqueue should be empty. Is it empty? %s\n", IsEmpty(pq) ? "TRUE" : "FALSE");
FreePQueue(pq);
printf("Hit return to continue: ");
{
string s = GetLine();
FreeBlock(s);
}
}
示例11: main
int main(){
// create queue
int queue[QUEUE_SIZE]={0};
int rear = 0;
int front = 0;
int choice;
while(1){
showInitile();
choice = getChoice();
switch(choice){
case 1:
displayQueue(queue);
break;
case 2:
Enqueue(queue, &rear, &front);
break;
case 3:
delqueue(queue, &rear, &front);
break;
case 4:
system("CLS");
break;
default:
printf("你壞壞\n");
break;
}
}
system("pause");
return 0;
}
示例12: shortestpath
//BFS algorithm
int shortestpath(Node *array, int Vnum, int root, int des)
{
int i,out,ss;
//create a queue
Queue *head=Initqueue();
Queue *path=Initqueue();
Node *travel,*p;
int *color = (int *)malloc(Vnum*sizeof(int));
int *father = (int *)malloc(Vnum*sizeof(int));
for(i=0;i<Vnum;i++)father[i]=i;
for(i=0;i<Vnum;i++)color[i]=white; //initialize colar
Enqueue(head,root);
color[root]=grey;
father[root]=root;
while(Isempty(head)!=1)
{
out = Dequeue(head);
travel=array+out;
for(p=travel->next;p!=NULL;p=p->next)
{
if(color[p->ID]==white)
{
Enqueue(head,p->ID);
color[p->ID]=grey;
father[p->ID]=out;
}
}
color[out]=black;
}
if(color[des]==white)
{
printf("Error: there is no path between %d and %d.",root,des);
ss=false;
}
else
{
//if there is a path, then print it out
//for(i=0;i<Vnum;i++)printf("%d is father of %d\n",father[i],i);
PrintPath(father,root,des);
ss=true;
}
Clearqueue(head);
Destroyqueue(head);
free(color);
free(father);
return ss;
}
示例13: main
int main()
{
Queue Q;
Q = CreateQueue(4);
Enqueue(1,Q);
Enqueue(2,Q);
Enqueue(3,Q);
Enqueue(4,Q);
printf("Size of queue is : %d and rear is :%d\n",Q->size,Q->rear);
Dequeue(Q);
printf("Size of queue is : %d and front is : %d\n",Q->size,Q->front);
return 0;
}
示例14: sizeof
/**
* In CPU-Transfer-Mode the API will add the length descriptor for us. In DMA mode we also use this behavior (it is,
* however, redundant to the HPRPC protocol ... maybe it'd be the best to change the protocol ...)
*
* In DMA mode we prefix the transfer with the transfer length (and set the MSB to signalize DMA mode)
* Here we add only a placeholder, later we will overwrite it during Send() (see OverwriteStartToken()).
*/
void CBufferedWriter::EnqueueDummyStartToken()
{
uint32_t lengthPlaceholder = 0;
uint32_t sizeofPlaceholder = sizeof(lengthPlaceholder);
Enqueue((uint8_t*)(&lengthPlaceholder), sizeofPlaceholder);
m_pLengthPrefix = (uint32_t*)(m_KernelBufCursor - sizeofPlaceholder); //remember this place, we will write the total length to it when we finally send the buffers
}
示例15: Serial_Enter
void Serial_Enter( serial_t serial)
{
pthread_t tid = pthread_self();
Enqueue(serial->queues[0],tid,NULL);
while( pthread_equal(serial->queues[0]->head->id,tid)==0);
pthread_mutex_lock(&(serial->mutexlock));
Dequeue(serial->queues[0]);
}