#include <stdlib.h>
#include "Item.h"

static Item *q;
static int N, head, tail;

void QUEUEinit(int maxN)
{
    q = (Item *)malloc((maxN+1)*sizeof(Item));
    N = maxN+1;
    head = N;
    tail = 0;
}

int QUEUEempty()
{
    return (head%N == tail);
}

void QUEUEput(Item item)
{
    q[tail++] = item;
    tail = tail%N;
}

Item QUEUEget()
{
    head = head %N;
    return q[head++];
}

 

相关文章:

  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-10-08
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
相关资源
相似解决方案