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 / QUEUE.CPP < prev    next >
C/C++ Source or Header  |  1990-09-26  |  4KB  |  161 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. //      Queue::get
  15. //      Queue::initIterator
  16. //      Queue::hashValue
  17. //
  18. // Description
  19. //
  20. //      Implementation of class Queue member functions.
  21. //
  22. // End ---------------------------------------------------------------------
  23.  
  24. // Interface Dependencies ---------------------------------------------------
  25.  
  26. #ifndef __CLSTYPES_H
  27. #include <clstypes.h>
  28. #endif
  29.  
  30. #ifndef __OBJECT_H
  31. #include <object.h>
  32. #endif
  33.  
  34. #ifndef __QUEUE_H
  35. #include <queue.h>
  36. #endif
  37.  
  38. // End Interface Dependencies ------------------------------------------------
  39.  
  40. // Implementation Dependencies ----------------------------------------------
  41.  
  42. #ifndef __DBLLIST_H
  43. #include <dbllist.h>
  44. #endif
  45.  
  46. // End Implementation Dependencies -------------------------------------------
  47.  
  48.  
  49. // Member Function //
  50.  
  51. Queue::~Queue()
  52.  
  53. // Summary -----------------------------------------------------------------
  54. //
  55. //      Destructor for a Queue object.
  56. //
  57. //        We don't do anything here, because the destructor for theQueue
  58. //        will take care of destroying the contained objects.
  59. //
  60. // End ---------------------------------------------------------------------
  61. {
  62. }
  63. // End Destructor //
  64.  
  65.  
  66. // Member Function //
  67.  
  68. Object& Queue::get()
  69.  
  70. // Summary -----------------------------------------------------------------
  71. //
  72. //      Gets an object from the queue.  The object becomes the ownership
  73. //      of the receiver.
  74. //
  75. // Return Value
  76. //
  77. //         firstIn
  78. //
  79. //         We return the element which is a the tail of the queue, i.e. the
  80. //         first element in to the queue.
  81. //
  82. // End ---------------------------------------------------------------------
  83. {
  84.     Object& temp = theQueue.peekAtTail();
  85.     if ( temp != NOOBJECT )
  86.         {
  87.         theQueue.detachFromTail( temp );
  88.         itemsInContainer--;
  89.         }
  90.     return temp;
  91. }
  92. // End Member Function Queue::get //
  93.  
  94.  
  95. // Member Function //
  96.  
  97. classType Queue::isA() const
  98.  
  99. // Summary -----------------------------------------------------------------
  100. //
  101. //      Returns a predefined value for the class Queue.
  102. //
  103. // Parameters
  104. //
  105. //      none
  106. //
  107. // End ---------------------------------------------------------------------
  108. {
  109.     return queueClass;
  110. }
  111. // End Member Function Queue::isA //
  112.  
  113.  
  114. // Member Function //
  115.  
  116. char *Queue::nameOf() const
  117.  
  118. // Summary -----------------------------------------------------------------
  119. //
  120. //      Returns the string "Queue".
  121. //
  122. // Parameters
  123. //
  124. //      none
  125. //
  126. // End ---------------------------------------------------------------------
  127. {
  128.     return "Queue";
  129. }
  130. // End Member Function Queue::nameOf //
  131.  
  132.  
  133. // Member Function //
  134.  
  135. hashValueType Queue::hashValue() const
  136.  
  137. // Summary -----------------------------------------------------------------
  138. //
  139. //      Returns the hash value of a queue.
  140. //
  141. // End ---------------------------------------------------------------------
  142. {
  143.     return hashValueType(0);
  144. }
  145. // End Member Function Queue::hashValue //
  146.  
  147. // Member Function //
  148.  
  149. ContainerIterator& Queue::initIterator() const
  150.  
  151. // Summary -----------------------------------------------------------------
  152. //
  153. //      Initializes an iterator for a queue.
  154. //
  155. // End ---------------------------------------------------------------------
  156. {
  157.     return *( (ContainerIterator *)new DoubleListIterator( theQueue ) );
  158. }
  159. // End Member Function Queue::initIterator //
  160.  
  161.