home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / L2 < prev    next >
Encoding:
Text File  |  1992-06-07  |  2.2 KB  |  74 lines

  1. #ifndef __RWTVASSLNK_H__
  2. #define __RWTVASSLNK_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWTValAssocLink: Key / Value association link
  7.  *
  8.  * $Header:   E:/vcs/rw/tvasslnk.h_v   1.0   02 Mar 1992 16:10:52   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave Software, Inc.
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  *
  16.  * Copyright (C) 1992. This software is subject to copyright 
  17.  * protection under the laws of the United States and other countries.
  18.  *
  19.  ***************************************************************************
  20.  *
  21.  * This class defines an association between a key of type K, and a
  22.  * value of type V in a singly-linked link, using value semantics.
  23.  *
  24.  * It has a single value constructor that just takes the key.
  25.  * This means that the value will be constructed using the default
  26.  * constructor for type V.  Usually this works just fine.  However, if the
  27.  * value (type V) is a builtin, then its value will be left undefined.
  28.  * Usually this also works fine.  However, if this is unsatisfactory,
  29.  * then you can supply your own definition that overrides the template-
  30.  * generated definition.  For an explanation of user-specified overrides
  31.  * of template-generated definitions, see Stroustrup II, sec. 8.4.1.
  32.  *
  33.  * Example:
  34.  *
  35.  *   RWTValAssocLink<int,double>::RWTValAssocLink(int i) :
  36.  *     _key(i)
  37.  *    {
  38.  *      _value = 0.0;    // Explicitly set the value to zero.
  39.  *    }
  40.  *
  41.  * 
  42.  ***************************************************************************
  43.  *
  44.  * $Log:   E:/vcs/rw/tvasslnk.h_v  $
  45.  * 
  46.  *    Rev 1.0   02 Mar 1992 16:10:52   KEFFER
  47.  * Initial revision.
  48.  */
  49.  
  50. #include "rw/islink.h"
  51.  
  52. template <class K, class V> struct RWExport RWTValAssocLink : public RWIsvSlink {
  53.   K        _key;
  54.   V        _value;
  55.   RWTValAssocLink(K key);
  56.   RWTValAssocLink(K key, V value) : _key(key), _value(value) { }
  57.  
  58.   RWBoolean    operator==(const RWTValAssocLink<K,V>& a){ return _key==a._key; }
  59. };
  60.  
  61. /*
  62.  * Template-generated single-value constructor.  This can be overridden
  63.  * by the user.
  64.  */
  65. template <class K, class V>
  66. RWTValAssocLink<K,V>::RWTValAssocLink(K key) :
  67.   _key(key)
  68. {
  69.  
  70. }
  71.  
  72. pragma pop_align_members();
  73. #endif    /* __RWTVASSLNK_H__ */
  74.