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

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // Contents ----------------------------------------------------------------
  4. //
  5. //      Association::isA
  6. //      Association::nameOf
  7. //         Association::printOn
  8. //      Association::hashValue
  9. //      Association::isEqual
  10. //      Association::isAssociation
  11. //
  12. // Description
  13. //
  14. //         Implementation of member functions for class Association.
  15. //
  16. // End ---------------------------------------------------------------------
  17.  
  18. // Interface Dependencies ---------------------------------------------------
  19.  
  20. #ifndef __IOSTREAM_H
  21. #include <iostream.h>
  22. #define __IOSTREAM_H
  23. #endif
  24.  
  25. #ifndef __CLSTYPES_H
  26. #include <clstypes.h>
  27. #endif
  28.  
  29. #ifndef __ASSOC_H
  30. #include <assoc.h>
  31. #endif
  32.  
  33. // End Interface Dependencies ------------------------------------------------
  34.  
  35. // Implementation Dependencies ----------------------------------------------
  36. // End Implementation Dependencies -------------------------------------------
  37.  
  38.  
  39. // Member Function //
  40.  
  41. Association::~Association()
  42.  
  43. // Summary -----------------------------------------------------------------
  44. //
  45. //      Destructor for an Association object.
  46. //
  47. //        We don't do anything here, because the key and value fields will
  48. //        be destroyed automatically.
  49. //
  50. // End ---------------------------------------------------------------------
  51. {
  52. }
  53. // End Destructor //
  54.  
  55.  
  56. // Member Function //
  57.  
  58. classType Association::isA() const
  59.  
  60. // Summary -----------------------------------------------------------------
  61. //
  62. //         Returns the class type of a association.
  63. //
  64. // End ---------------------------------------------------------------------
  65. {
  66.     return associationClass; 
  67. }
  68. // End Member Function Association::isA //
  69.  
  70.  
  71. // Member Function //
  72.  
  73. char *Association::nameOf() const
  74.  
  75. // Summary -----------------------------------------------------------------
  76. //
  77. //         Returns a pointer to the character string "Association."
  78. //
  79. // End ---------------------------------------------------------------------
  80. {
  81.     return "Association";
  82. }
  83. // End Member Function Association::isA //
  84.  
  85.  
  86. // Member Function //
  87.  
  88. void Association::printOn( ostream& outputStream ) const
  89.  
  90. // Summary -----------------------------------------------------------------
  91. //
  92. //         Displays the contents of this association object.
  93. //
  94. // Parameters
  95. //
  96. //         outputStream
  97. //
  98. //         The stream on which we are to display the association.
  99. //
  100. // End ---------------------------------------------------------------------
  101. {
  102.     outputStream << " " << nameOf() << " { ";
  103.     aKey.printOn( outputStream );
  104.     outputStream << ", ";
  105.     aValue.printOn( outputStream );
  106.     outputStream << " }\n";
  107. }
  108. // End Member Function //
  109.  
  110.  
  111. // Member Function //
  112.  
  113. hashValueType Association::hashValue() const
  114.  
  115. // Summary -----------------------------------------------------------------
  116. //
  117. //         Returns the hash value of an association.  We use the key's
  118. //      hash value.
  119. //
  120. // End ---------------------------------------------------------------------
  121. {
  122.     return aKey.hashValue();
  123. }
  124. // End Member Function Association::hashValue //
  125.  
  126.  
  127. // Member Function //
  128.  
  129. int Association::isEqual( const Object& toObject ) const
  130.  
  131. // Summary -----------------------------------------------------------------
  132. //
  133. //         Returns the hash value of an association.  We use the key's
  134. //      hash value.
  135. //
  136. // End ---------------------------------------------------------------------
  137. {
  138.     return aKey == ( (Association&)toObject ).key();
  139. }
  140. // End Member Function Association::isEqual //
  141.  
  142.  
  143. // Member Function //
  144.  
  145. int Association::isAssociation() const
  146.  
  147. // Summary -----------------------------------------------------------------
  148. //
  149. //         Indicates that the given object is an association.
  150. //
  151. // End ---------------------------------------------------------------------
  152. {
  153.     return 1;
  154. }
  155. // End Member Function Association::isEqual //
  156.  
  157.