Advertisement
Guest User

queType.h

a guest
Dec 5th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1.  
  2. #ifndef QUETYPE_H_INCLUDED
  3. #define QUETYPE_H_INCLUDED
  4.  
  5. // Header file for Queue ADT.
  6. #include <new>
  7. #include <cstddef>
  8. class FullQueue
  9. {};
  10.  
  11. class EmptyQueue
  12. {};
  13. typedef char ItemType;
  14.  
  15. struct NodeType;
  16.  
  17. class QueType
  18. {
  19. public:
  20. QueType();
  21. // Class constructor.
  22. // Because there is a default constructor, the precondition
  23. // that the queue has been initialized is omitted.
  24. QueType(int max);
  25. // Parameterized class constructor.
  26. ~QueType();
  27. // Class destructor.
  28. QueType(const QueType& anotherQue);
  29. // Copy constructor
  30. void MakeEmpty();
  31. // Function: Initializes the queue to an empty state.
  32. // Post: Queue is empty.
  33. bool IsEmpty() const;
  34. // Function: Determines whether the queue is empty.
  35. // Post: Function value = (queue is empty)
  36. bool IsFull() const;
  37. // Function: Determines whether the queue is full.
  38. // Post: Function value = (queue is full)
  39. void Enqueue(ItemType newItem);
  40. // Function: Adds newItem to the rear of the queue.
  41. // Post: If (queue is full) FullQueue exception is thrown
  42. // else newItem is at rear of queue.
  43. void Dequeue(ItemType& item);
  44. // Function: Removes front item from the queue and returns it in item.
  45. // Post: If (queue is empty) EmptyQueue exception is thrown
  46. // and item is undefined
  47. // else front element has been removed from queue and
  48. // item is a copy of removed element.
  49. private:
  50.  
  51. NodeType* front;
  52. NodeType* rear;
  53. };
  54.  
  55. #endif // QUETYPE_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement