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

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // Contents ----------------------------------------------------------------
  4. //
  5. //      Deque
  6. //
  7. // Description
  8. //
  9. //      Defines the class Deque.
  10. //
  11. // End ---------------------------------------------------------------------
  12.  
  13. // Interface Dependencies ---------------------------------------------------
  14.  
  15. #ifndef __DEQUE_H
  16. #define __DEQUE_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 Deque:  public Container
  44. {
  45. public:
  46.     virtual ~Deque();
  47.  
  48.             Object&         peekLeft() const { return theDeque.peekAtHead(); }
  49.             Object&         peekRight() const { return theDeque.peekAtTail(); }
  50.             Object&         getLeft();
  51.             Object&         getRight();
  52.             void            putLeft( Object& o )
  53.                                 { theDeque.addAtHead( o ); itemsInContainer++; }
  54.             void            putRight( Object& o )
  55.                                 { theDeque.addAtTail( o ); itemsInContainer++; }
  56.  
  57.     virtual ContainerIterator& initIterator() const;
  58.             ContainerIterator& initReverseIterator() const;
  59.  
  60.     virtual classType       isA() const;
  61.     virtual char           *nameOf() const;
  62.     virtual hashValueType   hashValue() const;
  63.  
  64. private:
  65.     DoubleList    theDeque;
  66. };
  67.  
  68. // Description -------------------------------------------------------------
  69. //
  70. //         Defines the container class Deque.  A deque is a double-ended queue.
  71. //      You may inspect, add, and remove elements at either end of the 
  72. //      deque.
  73. //
  74. // Public Members
  75. //
  76. //      peekLeft
  77. //
  78. //      Returns a reference to the object at the left end of the deque.
  79. //      The object is still owned by the deque.
  80. //
  81. //      peekRight
  82. //
  83. //      Returns a reference to the object at the right end of the deque.
  84. //      The object is still owned by the deque.
  85. //
  86. //      putLeft
  87. //
  88. //      Enqueues an object at the left end.
  89. //
  90. //      putRight
  91. //
  92. //      Enqueues an object at the right end.
  93. //
  94. //      getLeft
  95. //
  96. //      Dequeues an object from the left end.
  97. //
  98. //      getRight
  99. //
  100. //      Dequeues an object from the right end.
  101. //
  102. //      initIterator
  103. //
  104. //      Left-to-right Deque iterator initializer.
  105. //
  106. //      initReverseIterator
  107. //
  108. //      Right-to-left Deque iterator initializer.
  109. //
  110. //         isA
  111. //
  112. //         Returns the class type for a deque.
  113. //
  114. //         nameOf
  115. //
  116. //         Returns a pointer to the character string "Deque."
  117. //     
  118. //         hashValue
  119. //
  120. //         Returns a pre-defined value for deques.
  121. //
  122. // Inherited Members
  123. //
  124. //      Deque( Deque& )
  125. //
  126. //      Copy constructor.  Inherited from Container.
  127. //
  128. //      isEmpty
  129. //
  130. //         Inherited from Container.
  131. //
  132. //         isEqual
  133. //
  134. //         Inherited from Container.
  135. //
  136. //      forEach
  137. //
  138. //         Inherited from Container.
  139. //
  140. //      firstThat
  141. //
  142. //         Inherited from Container.
  143. //
  144. //      lastThat
  145. //
  146. //         Inherited from Container.
  147. //
  148. //      getItemsInContainer
  149. //
  150. //         Inherited from Container.
  151. //
  152. //      printOn
  153. //
  154. //         Inherited from Container.
  155. //
  156. //      printHeader
  157. //
  158. //         Inherited from Container.
  159. //
  160. //      printSeparator
  161. //
  162. //         Inherited from Container.
  163. //
  164. //      printTrailer
  165. //
  166. //         Inherited from Container.
  167. //
  168. // Private Members
  169. //
  170. //      theDeque
  171. //
  172. //      The implementation of the deque.
  173. //
  174. // End ---------------------------------------------------------------------
  175.  
  176.  
  177. #endif // ifndef __DEQUE_H //
  178.