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

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