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

  1. --
  2. -- Define the class skeleton for Element type
  3. --
  4. <code DEFINE_KEY>
  5. --
  6. <include k_user.tde>
  7. --
  8.  
  9. class $KEY_CLASS$
  10. {
  11. //-----------------------------------------------------------------------------
  12. // Required members for the key type.
  13. //-----------------------------------------------------------------------------
  14. public:
  15. <if ($DEFAULT_CONSTRUCTOR$)>
  16.      //------------------------------------------------------------------------
  17.      // Default constructor
  18.      //------------------------------------------------------------------------
  19.      $KEY_CLASS$()
  20. <   >$K_DEF_CONSTR_BODY$
  21. </if>
  22. <if (($K_EQUALITY$) | ($EQUALITY$)) >
  23.      //------------------------------------------------------------------------
  24.      // Equality test
  25.      //------------------------------------------------------------------------
  26.      IBoolean operator== ($KEY_CLASS$ const& a$KEY_CLASS$) const
  27. <   >$K_EQUAL_BODY$
  28. </if>
  29. <if (($K_ORDERING$) | ($ORDERING$)) >
  30.      //------------------------------------------------------------------------
  31.      // Ordering relation between $KEY_CLASS$ objects.
  32.      //------------------------------------------------------------------------
  33.      IBoolean operator< ($KEY_CLASS$ const& a$KEY_CLASS$) const
  34. <   >$K_ORDER_BODY$
  35. </if>
  36. //-----------------------------------------------------------------------------
  37. // Additional members (customization)
  38. //-----------------------------------------------------------------------------
  39. $K_CUSTOMIZATION$
  40. };   // End of class $KEY_CLASS$
  41. <if ($K_HASH_FUNCTION$)>
  42.  
  43. $DEFINE_K_HASH$\<>
  44. </if>
  45. </code DEFINE_KEY>
  46.  
  47.  
  48. <code DEFINE_K_HASH>
  49. //-----------------------------------------------------------------------------
  50. // Need a hash function for the key type
  51. //-----------------------------------------------------------------------------
  52. inline unsigned long hash($KEY_TYPE$ const& a$KEY_CLASS$, unsigned long hashInput)
  53. <if ($USER_DEFINED_KEY$)>
  54. $K_HASH_BODY$
  55. <else>\<if ($KEY_PTR$)>
  56. -- When key type is pointer to predefined type,
  57. -- do hashing on the actual value
  58. {
  59.      \<if ($KEY_NUMERIC_TYPE$)>
  60.    return hash(*a$KEY_CLASS$, hashInput);
  61.      \<else>
  62.    return hash((const char*)*a$KEY_CLASS$, hashInput);
  63.      \</if>
  64. }
  65. </if>\</if>
  66. </code DEFINE_K_HASH>
  67.