home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / source / theatrix / queue.cpp < prev    next >
C/C++ Source or Header  |  1995-04-26  |  917b  |  49 lines

  1. /*-----------------------------------------------------------------------*/
  2. /*------ static circular queue with minimal error checking --------------*/
  3. /*-----------------------------------------------------------------------*/
  4.  
  5. #include "standard.h"
  6. #include "queue.h"
  7.  
  8.  
  9. Queue::Queue()
  10.   {
  11.   head=0;
  12.   tail=0;
  13.   }
  14.  
  15. void Queue::put(int newitem,int data1,int data2)
  16.   {
  17.   a[head].msg=newitem;
  18.   a[head].data1=data1;
  19.   a[head].data2=data2;
  20.   head=inc(head);
  21.   }
  22.  
  23. void Queue::get(int* msg,int* data1,int* data2)
  24.   {
  25.   *msg=a[tail].msg;
  26.   *data1=a[tail].data1;
  27.   *data2=a[tail].data2;
  28.   tail=inc(tail);
  29.   }
  30.  
  31. int  Queue::isfull()
  32.   {
  33.   int temp=tail;
  34.   temp=inc(temp);
  35.   if (temp==head)  return(TRUE);
  36.   else  return(FALSE);
  37.   }
  38.  
  39. int  Queue::isempty()
  40.   {
  41.   if (head==tail)  return(TRUE);
  42.   else  return(FALSE);
  43.   }
  44.  
  45. int  Queue::inc(int num)
  46.   {
  47.   return((num+1)%QLEN);
  48.   }
  49.