home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tcpp / classlib / source / deque.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-10  |  4.5 KB  |  184 lines

  1. //
  2. // This file contains proprietary information of Borland International.
  3. // Copying or reproduction without prior written approval is prohibited.
  4. //
  5. // Copyright (c) 1990
  6. // Borland International
  7. // 1800 Scotts Valley Dr.
  8. // Scotts Valley, CA 95066
  9. // (408) 438-8400
  10. //
  11.  
  12. // Contents ----------------------------------------------------------------
  13. //
  14. //      Deque::isA
  15. //      Deque::nameOf
  16. //      Deque::getLeft
  17. //      Deque::getRight
  18. //      Deque::initIterator
  19. //      Deque::initReverseIterator
  20. //      Deque::hashValue
  21. //
  22. // Description
  23. //
  24. //      Implementation of class Deque member functions.
  25. //
  26. // End ---------------------------------------------------------------------
  27.  
  28. // Interface Dependencies ---------------------------------------------------
  29.  
  30. #ifndef __IOSTREAM_H
  31. #include <iostream.h>
  32. #define __IOSTREAM_H
  33. #endif
  34.  
  35. #ifndef __CLSTYPES_H
  36. #include <clstypes.h>
  37. #endif
  38.  
  39. #ifndef __OBJECT_H
  40. #include <object.h>
  41. #endif
  42.  
  43. #ifndef __DEQUE_H
  44. #include <deque.h>
  45. #endif
  46.  
  47. // End Interface Dependencies ------------------------------------------------
  48.  
  49. // Implementation Dependencies ----------------------------------------------
  50.  
  51. #ifndef __DBLLIST_H
  52. #include <dbllist.h>
  53. #endif
  54.  
  55. // End Implementation Dependencies -------------------------------------------
  56.  
  57.  
  58. // Member Function //
  59.  
  60. Deque::~Deque()
  61.  
  62. // Summary -----------------------------------------------------------------
  63. //
  64. //      Destructor for a Deque object.
  65. //
  66. //        We don't do anything here, because the destructor for theDeque
  67. //        will destroy all the objects in the Deque.
  68. //
  69. // End ---------------------------------------------------------------------
  70. {
  71. }
  72. // End Destructor //
  73.  
  74.  
  75. // Member Function //
  76.  
  77. classType Deque::isA() const
  78.  
  79. // Summary -----------------------------------------------------------------
  80. //
  81. //         Returns the class type of a double-ended queue.
  82. //
  83. // End ---------------------------------------------------------------------
  84. {
  85.     return dequeClass; 
  86. }
  87. // End Member Function Deque::isA //
  88.  
  89.  
  90. // Member Function //
  91.  
  92. char *Deque::nameOf() const
  93.  
  94. // Summary -----------------------------------------------------------------
  95. //
  96. //         Returns a pointer to the character string "Deque."
  97. //
  98. // End ---------------------------------------------------------------------
  99. {
  100.     return "Deque";
  101. }
  102. // End Member Function Deque::nameOf //
  103.  
  104.  
  105. // Member Function //
  106.  
  107. Object& Deque::getLeft()
  108.  
  109. // Summary -----------------------------------------------------------------
  110. //
  111. //      Gets an object from the left end of the deque.  The object becomes 
  112. //      the ownership of the receiver.
  113. //
  114. // End ---------------------------------------------------------------------
  115. {
  116.     Object& temp = theDeque.peekAtHead();
  117.     theDeque.detachFromHead( temp );
  118.     return temp;
  119. }
  120. // End Member Function Deque::getLeft //
  121.  
  122.  
  123. // Member Function //
  124.  
  125. Object& Deque::getRight()
  126.  
  127. // Summary -----------------------------------------------------------------
  128. //
  129. //      Gets an object from the right end of the deque.  The object becomes 
  130. //      the ownership of the receiver.
  131. //
  132. // End ---------------------------------------------------------------------
  133. {
  134.     Object& temp = theDeque.peekAtTail();
  135.     theDeque.detachFromTail( temp );
  136.     return temp;
  137. }
  138. // End Member Function Deque::getLeft //
  139.  
  140.  
  141. // Member Function //
  142.  
  143. ContainerIterator& Deque::initIterator() const
  144.  
  145. // Summary -----------------------------------------------------------------
  146. //
  147. //      Initializes an iterator for a deque.
  148. //
  149. // End ---------------------------------------------------------------------
  150. {
  151.     return *( (ContainerIterator *)new DoubleListIterator( this->theDeque ) );
  152. }
  153. // End Member Function Deque::initIterator //
  154.  
  155.  
  156. // Member Function //
  157.  
  158. ContainerIterator& Deque::initReverseIterator() const
  159.  
  160. // Summary -----------------------------------------------------------------
  161. //
  162. //      Initializes a right to left iterator for a deque.
  163. //
  164. // End ---------------------------------------------------------------------
  165. {
  166.     return *((ContainerIterator *)new DoubleListIterator( this->theDeque, 0 ));
  167. }
  168. // End Member Function Deque::initReverseIterator //
  169.  
  170.  
  171. // Member Function //
  172.  
  173. hashValueType Deque::hashValue() const
  174.  
  175. // Summary -----------------------------------------------------------------
  176. //
  177. //      Returns the hash value of a deque.
  178. //
  179. // End ---------------------------------------------------------------------
  180. {
  181.     return hashValueType(0);
  182. }
  183. // End Member Function Deque::hashValue //
  184.