Habsburg

red_pokazivac.h

Dec 11th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #ifndef RED_POKAZIVAC_H
  2. #define RED_POKAZIVAC_H
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. struct tPerson {
  7.     string name, lname;
  8.     bool sex;
  9.     string dmy;
  10.     int ai,bi,ci,di;
  11. };
  12.  
  13. struct tRed {
  14.     tPerson Person;
  15.     tRed *next;
  16. };
  17.  
  18. struct tPokRed {
  19.     tRed *rear;
  20.     tRed *front;
  21. };
  22.  
  23. tPokRed PK;
  24.  
  25. template <typename T>
  26. tPerson FrontQ (T *Red) {
  27.     return Red->next->Person;
  28. }
  29.  
  30. template <typename D, typename T>
  31. void EnQueueQ (D person, T *Red) {
  32.     T *qRed = new T;
  33.     qRed->next = NULL;
  34.     qRed->Person = person;
  35.     PK.rear = PK.rear->next = qRed;
  36. }
  37.  
  38. template <typename T>
  39. void DeQueueQ (T *&Red) {
  40.     T *qRed = Red;
  41.     Red = PK.front = PK.front->next;
  42.     delete qRed;
  43. }
  44.  
  45. template <typename T>
  46. bool IsEmptyQ (T *Red) {
  47.     return (PK.rear == PK.front);
  48. }
  49.  
  50. template <typename T>
  51. void InitQ (T *Red) {
  52.     PK.rear = PK.front = Red;
  53. }
  54.  
  55. #endif // RED_POKAZIVAC_H
Advertisement
Add Comment
Please, Sign In to add comment