Exemplo n.º 1
0
void EnQ(int element, q_t *p)
{
	if(!FullQ(p))//if Queue is not full
	{
		p->q[p->tail] = element;
		p->tail = p->tail + 1;
		if(p->tail==Q_SIZE)//if tail is at index 20 then reset tail to 0
			p->tail = 0;
		p->count = p->count + 1;
	}
}
Exemplo n.º 2
0
int EnQueueQ(struct sequeue *sq,datatype x){
	if(FullQ(sq)){
		printf("\nqueue if full \n");
		return 0;
	}else{
		sq->data[(sq->rear+1)%MAXSIZE] = x;
		sq->rear++;
		sq->quelen++;
		return 1;
	}
}
void EnQ(int id, q_t *p) // append id to p->q[tail] if queue has space
{
   if(FullQ(p))
   {
      cons_printf("Queue is full, can't enqueue!\n");
      return;
   }
   p->q[p->tail] = id;
   p->tail++;
   if(p->tail == Q_SIZE) p->tail = 0;   // wrap around
   p->count++;
}
Exemplo n.º 4
0
void EnQ(int element, q_t *p)
{
	if (FullQ(p)) {
		cons_printf("Queue is full, can't enqueue!\n");
		return;
	}
	p->q[p->tail] = element;

	p->tail += 1;

	if (p->tail >= Q_SIZE) {
		p->tail = 0;
	}

	p->count += 1;
}