# Posted By

kdomic on 12/03/11

# Statistics

Viewed 326 times
Favorited by 0 user(s)

# red_pokazivaci.h

/ Published in: C++

Simulacija reda u lijeÄniÄkoj ordinaciji - red_pokazivaci.h

Copy this code and paste it in your HTML
1. struct tdata{
2. int x,y, prioritet, rb;
3. tdata *next;
4. };
5.
6. struct tlist{
7. tdata *front;
8. tdata *rear;
9. };
10.
11. bool IsEmptyQ(tlist *Q){
12. if(Q->front==Q->rear)
13. return true;
14. return false;
15. }
16.
17. tdata FronQ(tlist *Q){
18. tdata data;
19. data.x = 0; data.y = 0; data.rb = 0; data.prioritet = 0;
20. if(IsEmptyQ(Q)) return data;
21. return *Q->front->next;
22. }
23.
24. void EnQueueQ(tdata x,tlist *Q){
25. tdata *novi = new tdata;
26. memcpy(novi,&x,sizeof(tdata));
27. novi->next = NULL;
28. if(IsEmptyQ(Q)){
29. Q->front->next = novi;
30. Q->rear = novi;
31. } else {
32. Q->rear->next = novi;
33. Q->rear = novi;
34. }
35. }
36.
37. bool DeQueueQ(tlist *Q){
38. if(IsEmptyQ(Q)) return false;
39. tdata *first = Q->front->next;
40. if(first->next)
41. Q->front->next = first->next;
42. else
43. Q->front = Q->rear;
44. }
45.
46. tlist* InitQ(tlist *Q){
47. Q = new tlist;
48. Q->front = new tdata;
49. Q->front->next = NULL;
50. Q->rear = Q->front;
51. return Q;
52. }