Return to Snippet

Revision: 53949
at December 3, 2011 08:26 by mdzeko


Initial Code
#include<iostream>
struct tpacijent
{
  int cek, traj, prioritet, redni;
  tpacijent *next;
};
 
struct tred
{
  tpacijent *front;
  tpacijent *rear;
};

/////////////////////////////////////

tred* InitQ(tred *q)
{
      q = new tred;
      q->front = new tpacijent;
      q->front->next = NULL;
      q->rear = q->front;
      return q;
}

/////////////////////////////////////

bool IsEmptyQ(tred *q)
{
  if(q->front==q->rear)
  return 1;
  return 0;
}

/////////////////////////////////////

tpacijent FronQ(tred *q)
{
          if(!IsEmptyQ(q)) 
          return *q->front->next;
}

/////////////////////////////////////

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

/////////////////////////////////////

bool DeQueueQ(tred *q)
{
  if(IsEmptyQ(q)) 
  return false;
  tpacijent *first = q->front->next;
  if(first->next)
  q->front->next = first->next;
  else
  q->front = q->rear;
}

Initial URL


Initial Description
naknadno dodana biblioteka zaglavlja red_pokazivac.h

Initial Title
red_pokazivac.h

Initial Tags


Initial Language
C++