home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP10-8.ZIP / CLASSSRC.ZIP / DEQUE.CPP < prev    next >
C/C++ Source or Header  |  1990-09-26  |  5KB  |  192 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.     if( temp != NOOBJECT )
  118.         {
  119.         theDeque.detachFromHead( temp );
  120.         itemsInContainer--;
  121.         }
  122.     return temp;
  123. }
  124. // End Member Function Deque::getLeft //
  125.  
  126.  
  127. // Member Function //
  128.  
  129. Object& Deque::getRight()
  130.  
  131. // Summary -----------------------------------------------------------------
  132. //
  133. //      Gets an object from the right end of the deque.  The object becomes 
  134. //      the ownership of the receiver.
  135. //
  136. // End ---------------------------------------------------------------------
  137. {
  138.     Object& temp = theDeque.peekAtTail();
  139.     if( temp != NOOBJECT )
  140.         {
  141.         theDeque.detachFromTail( temp );
  142.         itemsInContainer--;
  143.         }
  144.     return temp;
  145. }
  146. // End Member Function Deque::getLeft //
  147.  
  148.  
  149. // Member Function //
  150.  
  151. ContainerIterator& Deque::initIterator() const
  152.  
  153. // Summary -----------------------------------------------------------------
  154. //
  155. //      Initializes an iterator for a deque.
  156. //
  157. // End ---------------------------------------------------------------------
  158. {
  159.     return *( (ContainerIterator *)new DoubleListIterator( this->theDeque ) );
  160. }
  161. // End Member Function Deque::initIterator //
  162.  
  163.  
  164. // Member Function //
  165.  
  166. ContainerIterator& Deque::initReverseIterator() const
  167.  
  168. // Summary -----------------------------------------------------------------
  169. //
  170. //      Initializes a right to left iterator for a deque.
  171. //
  172. // End ---------------------------------------------------------------------
  173. {
  174.     return *((ContainerIterator *)new DoubleListIterator( this->theDeque, 0 ));
  175. }
  176. // End Member Function Deque::initReverseIterator //
  177.  
  178.  
  179. // Member Function //
  180.  
  181. hashValueType Deque::hashValue() const
  182.  
  183. // Summary -----------------------------------------------------------------
  184. //
  185. //      Returns the hash value of a deque.
  186. //
  187. // End ---------------------------------------------------------------------
  188. {
  189.     return hashValueType(0);
  190. }
  191. // End Member Function Deque::hashValue //
  192.