Example #1
0
void MachineModel::waitFor_qEmpty()
{
// while waiting maintain the temperatures
  while(!qEmpty()) {
    manage(true);
  }
}
Example #2
0
void main(void) 
{
    int k;
    Queue* q = qCreate(10);
    for (int i = 0; i < 16; ++i) {
        qEnqueue(q, i);
    }
    while (!qEmpty(q)) {
        printf("%d ", qDequeue(q));
        printf(" (size left = %d)\n",  qSize(q));
    }
    for (int i = 0; i < 16; ++i) {
        qEnqueue(q, i);
        printf("(size = %d)\n",  qSize(q));
    }

    Stack s;
    stackCreate(&s, 128);

    for (int i = 0; i < 255; ++i) {
        stackPush(&s, i);
    }

    while (!stackEmpty(&s)) {
        printf("%d ", stackTop(&s));
        stackPop(&s);
    }
}
Example #3
0
void MachineModel::dQMove()
{
  if(!qEmpty())
  {
    byte t = (tail+1)%BUFFER_SIZE;  
	cdda[t]->dda_start();
	tail = t;
  }
}
Example #4
0
int qDequeue(Queue* q)
{
    if (!qEmpty(q)) {
        int v = q->data[q->front];
        q->front = (q->front + 1) % q->total;
        return v;
    }

    return 0;
}
Example #5
0
/* Removes the element on top of the stack */
void stackPop(Stack *stack) {
    int qsize = qSize(stack->q);
    int buf[qsize];

    int i = 0;
    while (!qEmpty(stack->q)) {
        buf[i++] = qDequeue(stack->q);
    }

    for (i = 0; i < qsize -1; ++i) {
        qEnqueue(stack->q, buf[i]);
    }
}
Example #6
0
/* Get the top element */
int stackTop(Stack *stack) {
    int qsize = qSize(stack->q);
    int buf[qsize];

    int i = 0;
    while (!qEmpty(stack->q)) {
        buf[i++] = qDequeue(stack->q);
    }

    for (i = 0; i < qsize; ++i) {
        qEnqueue(stack->q, buf[i]);
    }

    return buf[i - 1];
}
Example #7
0
/* Return whether the stack is empty */
bool stackEmpty(Stack *stack) {
    return qEmpty(stack->q);
}