home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / macros / k_user.tde < prev    next >
Encoding:
Text File  |  1996-02-22  |  3.1 KB  |  93 lines

  1. <code _K_USER_TDE_>
  2. --
  3. -- This file contains code sections for customizing the
  4. -- key type class.
  5. --
  6.  
  7. <code K_CUSTOMIZATION>
  8. ------------------------------------------------------
  9. -- Application specific functions and data.
  10. -- These will be in addition to the required methods.
  11. ------------------------------------------------------
  12. public:
  13.      //------------------------------------------------------------------------
  14.      // Constructor to initialize private class members
  15.      //------------------------------------------------------------------------
  16.      $KEY_CLASS$(int count) :
  17.           iCount(count) {}
  18.  
  19.      //------------------------------------------------------------------------
  20.      // Overload the output operator to print out the contents of the
  21.      // collection. The following is an example of printing out the
  22.      // count member function of the $KEY_CLASS$.
  23.      //------------------------------------------------------------------------
  24.      friend
  25.      ostream& operator<< (ostream& os, $KEY_CLASS$ const& a$KEY_CLASS$)
  26.      {
  27.        return os << a$KEY_CLASS$.iCount;
  28.      }
  29.  
  30.      //------------------------------------------------------------------------
  31.      // Define access method to the private members of the key class
  32.      //------------------------------------------------------------------------
  33.      int const& count() const
  34.      {
  35.         return iCount;
  36.      }
  37.  
  38. private:
  39.      //------------------------------------------------------------------------
  40.      // Private members of $KEY_CLASS$.
  41.      //------------------------------------------------------------------------
  42.      int iCount;
  43. </code K_CUSTOMIZATION>
  44.  
  45.  
  46. <code K_DEF_CONSTR_BODY>
  47. -------------------------------------------------------
  48. -- Default constructor implementation for key type
  49. -------------------------------------------------------
  50. --   $KEY_CLASS$()
  51.      {
  52.      }
  53. </code K_DEF_CONSTR_BODY>
  54.  
  55.  
  56. <code K_EQUAL_BODY>
  57. ----------------------------------------------------------------
  58. -- Equality operator implementation for key type
  59. ----------------------------------------------------------------
  60. --   IBoolean operator== ($KEY_CLASS$ const& a$KEY_CLASS$) const
  61.      {
  62.         return (iCount == a$KEY_CLASS$.iCount);
  63.      }
  64. </code K_EQUAL_BODY>
  65.  
  66.  
  67. <code K_ORDER_BODY>
  68. ----------------------------------------------------------------
  69. -- Ordering operator implementation for key type
  70. ----------------------------------------------------------------
  71. --   IBoolean operator< ($KEY_CLASS$ const& a$KEY_CLASS$) const
  72.      {
  73.         return (iCount < a$KEY_CLASS$.iCount);
  74.      }
  75. </code K_ORDER_BODY>
  76.  
  77. <code K_HASH_BODY>
  78. ----------------------------------------------------------------
  79. -- Hash function implementation
  80. ----------------------------------------------------------------
  81. -- inline unsigned long hash($KEY_TYPE$ const& a$KEY_CLASS$, unsigned long hashInput)
  82. {
  83. <if ($KEY_PTR$)>
  84.    return hash(a$KEY_CLASS$->count(), hashInput);
  85. <else>
  86.    return hash(a$KEY_CLASS$.count(), hashInput);
  87. </if>
  88. }
  89. </code K_HASH_BODY>
  90.  
  91.  
  92. </code _K_USER_TDE_>
  93.