home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 1.ddi / CLASSINC.ZIP / QUEUE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  3.4 KB  |  167 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // Contents ----------------------------------------------------------------
  4. //
  5. //      Queue
  6. //
  7. // Description
  8. //
  9. //      Defines the class Queue.
  10. //
  11. // End ---------------------------------------------------------------------
  12.  
  13. // Interface Dependencies ---------------------------------------------------
  14.  
  15. #ifndef __QUEUE_H
  16. #define __QUEUE_H
  17.  
  18. #ifndef __IOSTREAM_H
  19. #include <iostream.h>
  20. #define __IOSTREAM_H
  21. #endif
  22.  
  23. #ifndef __CLSTYPES_H
  24. #include "clstypes.h"
  25. #endif
  26.  
  27. #ifndef __OBJECT_H
  28. #include "object.h"
  29. #endif
  30.  
  31. #ifndef __CONTAIN_H
  32. #include "contain.h"
  33. #endif
  34.  
  35. #ifndef __DBLLIST_H
  36. #include "dbllist.h"
  37. #endif
  38.  
  39. // End Interface Dependencies ------------------------------------------------
  40.  
  41. // Class //
  42.  
  43. class Queue:  public Container
  44. {
  45. public:
  46.     virtual ~Queue();
  47.  
  48.             Object&         peekLeft() const { return theQueue.peekAtHead(); }
  49.             Object&         peekRight() const { return theQueue.peekAtTail(); }
  50.             Object&         get();
  51.             void            put( Object& o ) { theQueue.addAtHead( o ); itemsInContainer++; }
  52.  
  53.     virtual ContainerIterator& initIterator() const;
  54.  
  55.     virtual classType       isA() const;
  56.     virtual char           *nameOf() const;
  57.     virtual hashValueType   hashValue() const;
  58.  
  59. private:
  60.     DoubleList    theQueue;
  61. };
  62.  
  63. // Description -------------------------------------------------------------
  64. //
  65. //     Defines the container class Queue.  A queue is a FIFO object.
  66. //      You may inspect elements at either end of the queue, however,
  67. //      you may only remove objects at one end and add objects at the
  68. //      other.  The left end is the end at which objects are enqueued.
  69. //      The right end is where objects may be retrieved.
  70. //
  71. // Public Members
  72. //
  73. //      peekLeft
  74. //
  75. //      Returns a reference to the object at the left end of the queue.
  76. //      The object is still owned by the queue.
  77. //
  78. //      peekRight
  79. //
  80. //      Returns a reference to the object at the right end of the queue.
  81. //      The object is still owned by the queue.
  82. //
  83. //      put
  84. //
  85. //      Enqueues an object.
  86. //
  87. //      get
  88. //
  89. //      Dequeues an object.
  90. //
  91. //      initIterator
  92. //
  93. //      Left-to-right Queue iterator initializer.
  94. //
  95. //     isA
  96. //
  97. //     Returns the class type for a queue.
  98. //
  99. //     nameOf
  100. //
  101. //     Returns a pointer to the character string "Queue."
  102. //     
  103. //     hashValue
  104. //
  105. //     Returns a pre-defined value for queues.
  106. //
  107. // Inherited Members
  108. //
  109. //      Queue( Queue& )
  110. //
  111. //      Copy constructor.  Inherited from Container.
  112. //
  113. //      isEmpty
  114. //
  115. //     Inherited from Container.
  116. //
  117. //     operator ==
  118. //
  119. //     Inherited from Container.
  120. //
  121. //      forEach
  122. //
  123. //     Inherited from Container.
  124. //
  125. //      firstThat
  126. //
  127. //     Inherited from Container.
  128. //
  129. //      lastThat
  130. //
  131. //     Inherited from Container.
  132. //
  133. //      getItemsInContainer
  134. //
  135. //     Inherited from Container.
  136. //
  137. //      itemsInContainer
  138. //
  139. //     Inherited from Container.
  140. //
  141. //      printOn
  142. //
  143. //     Inherited from Container.
  144. //
  145. //      printHeader
  146. //
  147. //     Inherited from Container.
  148. //
  149. //      printSeparator
  150. //
  151. //     Inherited from Container.
  152. //
  153. //      printTrailer
  154. //
  155. //     Inherited from Container.
  156. //
  157. // Private Members
  158. //
  159. //      theQueue
  160. //
  161. //      The implementation of the queue.
  162. //
  163. // End ---------------------------------------------------------------------
  164.  
  165.  
  166. #endif // ifndef __QUEUE_H //
  167.