/ Published in: C++
Simulacija reda u lijeÄniÄkoj ordinaciji - red_pokazivaci.h
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; }