Return to Snippet

Revision: 53938
at December 3, 2011 07:35 by kdomic


Initial Code
struct tdata{
  int x,y, prioritet, rb;
  tdata *next;
};

struct tlist{
  tdata *front;
  tdata *rear;
};

bool IsEmptyQ(tlist *Q){
  if(Q->front==Q->rear)
    return true;
  return false;
}

tdata FronQ(tlist *Q){
  tdata data;
  data.x = 0; data.y = 0; data.rb = 0; data.prioritet = 0;
  if(IsEmptyQ(Q)) return data;
  return *Q->front->next;
}

void EnQueueQ(tdata x,tlist *Q){
  tdata *novi = new tdata;
  memcpy(novi,&x,sizeof(tdata));
  novi->next = NULL;
  if(IsEmptyQ(Q)){
    Q->front->next = novi;
    Q->rear = novi;
  } else {
    Q->rear->next = novi;
    Q->rear = novi;
  }
}

bool DeQueueQ(tlist *Q){
  if(IsEmptyQ(Q)) return false;
  tdata *first = Q->front->next;
  if(first->next)
    Q->front->next = first->next;
  else
    Q->front = Q->rear;
}

tlist* InitQ(tlist *Q){
  Q = new tlist;
  Q->front = new tdata;
  Q->front->next = NULL;
  Q->rear = Q->front;
  return Q;
}

Initial URL

                                

Initial Description
Simulacija reda u liječničkoj ordinaciji - red_pokazivaci.h

Initial Title
red_pokazivaci.h

Initial Tags
c++

Initial Language
C++