void Enqueue(struct ArrayQueue *Q, int data){ if(!isFullQueue(Q)){ Q->array[++Q->tail%Q->capacity]=data; Q->num++; //printf("%d \n",Q->num); } }
/** * 向队列queue的队尾插入元素element */ void push(Queue * queue,int element) { if (isFullQueue(queue)) { printf("队列已满,正在增加新空间。。。\n"); queue->length =queue->length+INCREMENT; queue->data = realloc(queue->data, sizeof(int) * queue->length); } queue->tail++; queue->data[queue->tail] = element; }
void enQueue(struct queue* Q, int data){ if(isFullQueue(Q)) printf("\nQueue Full!"); else{ Q->rear = (Q->rear+1)%q->capasity; q->array[Q->rear] = data; if(Q->front == -1) Q->front = Q->rear; } }
/* * append a new version to the ring-queue of one tuple. */ void EnQueue(Record * r, TransactionId tid, TupleId value) { if(isFullQueue(r)) { printf("EnQueue failed, %d %d %d\n",r->front,r->rear,r->lcommit); exit(-1); } r->VersionList[r->rear].tid = tid; r->VersionList[r->rear].value=value; r->rear = (r->rear + 1) % VERSIONMAX; }
void enqueue(int* queue,int data){ if(!isFullQueue()){ ++rear; rear = rear % MAXLENGTH; printf("rear: %d\n", rear); queue[rear] = data; } else{ fullQueue(); return ; } }
void insert (CQUEUE_p_t queue, char * item) { if (isFullQueue(*queue)) { printf("\n\tQUEUE OVERFLOW!\n\n"); return; } if (isEmptyQueue(*queue)) queue->front = queue->rear = 0; else queue->rear = (queue->rear + 1)%SIZE; *(queue->arr + queue->rear) = item; }
// 将数据元素item插入队列Q中; void append(Queue* q, int item) { QueueNode* t = NULL; if (!isFullQueue(q)) { t = (QueueNode*)malloc(sizeof(QueueNode)); t->element = item; t->next = NULL; if (isEmptyQueue(q)) q->first = q->last = t; else q->last->next = t; q->last = t; q->currentSize++; //printf("add %d\n", item); //为了方便观察打印信息 } else { printf("Queue is Full!\n"); } }
void Enqueue (queue *Q,int data) { if(isFullQueue((Q))) printf("Queue is full !!! Insertion not possible !!! Queue Overflow\n"); else { if(Q->tail==Q->size-1) Q->tail=0; else { ++Q->tail; Q->array[Q->tail]=data; } if(Q->head==-1) Q->head=Q->tail; } }