home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iiksslst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  4.8 KB  |  142 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
  19. #pragma pack (4)
  20.  
  21. // ---
  22. // IKeySortedSetAsListOps
  23. // ---
  24.  
  25. // public members
  26.  
  27. template <class Element, class Key,
  28.           class ElementOps, class Implementation>
  29. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  30. IKeySortedSetAsListOps (INumber numberOfElements)
  31. : ivElementOps (),
  32.   ivBase (numberOfElements),
  33.   ivImpl (*this, numberOfElements)
  34. {
  35. }
  36.  
  37. template <class Element, class Key,
  38.           class ElementOps, class Implementation>
  39. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  40. IKeySortedSetAsListOps (INumber numberOfElements, void* opsArg)
  41. : ivElementOps (opsArg),
  42.   ivBase (numberOfElements, opsArg),
  43.   ivImpl (*this, numberOfElements)
  44. {
  45. }
  46.  
  47. template <class Element, class Key,
  48.           class ElementOps, class Implementation>
  49. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  50. IKeySortedSetAsListOps
  51.   (IKeySortedSetAsListOps
  52.     <Element, Key, ElementOps, Implementation> const& collection)
  53. : ivElementOps (collection.ivElementOps),
  54.   ivBase (collection.ivBase),
  55.   ivImpl (*this, collection.ivImpl)
  56. {
  57. }
  58.  
  59. template <class Element, class Key,
  60.           class ElementOps, class Implementation>
  61. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  62. ~IKeySortedSetAsListOps ()
  63. {
  64. }
  65.  
  66. template <class Element, class Key,
  67.           class ElementOps, class Implementation>
  68. IACollectionImpl*
  69. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  70. Clone () const
  71. { return (Implementation*) *new Self (*this);
  72. }
  73.  
  74. template <class Element, class Key,
  75.           class ElementOps, class Implementation>
  76. long
  77. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  78. CompareKeys (void const* arg1, void const* arg2, IArgType argType) const
  79. { long comp = 0;
  80.   switch (argType) {
  81.     case kElementElement: {
  82.       comp = ivElementOps.keyOps.Compare
  83.         (ivElementOps.Key (*(Element const*)arg1),
  84.          ivElementOps.Key (*(Element const*)arg2));
  85.       break;
  86.     }
  87.     case kElementKey: {
  88.       comp = ivElementOps.keyOps.Compare
  89.         (ivElementOps.Key (*(Element const*)arg1),
  90.          IKeyForOps ((Key const*)arg2));
  91.       break;
  92.     }
  93.     case kKeyKey: {
  94.       comp = ivElementOps.keyOps.Compare
  95.         (IKeyForOps ((Key const*)arg1), IKeyForOps ((Key const*)arg2));
  96.     }
  97.   }
  98.   return comp;
  99. }
  100.  
  101. template <class Element, class _Key,
  102.           class ElementOps, class Implementation>
  103. void*
  104. IKeySortedSetAsListOps <Element, _Key, ElementOps, Implementation>::
  105. Key (void const* element) const
  106. { return IKeyFromOps (ivElementOps.Key (*(Element const*)element));
  107. }
  108.  
  109. template <class Element, class Key,
  110.           class ElementOps, class Implementation>
  111. TStream&
  112. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  113. operator<<= (TStream& fromWhere)
  114. { return (ivElementOps <<= fromWhere);
  115. }
  116.  
  117. template <class Element, class Key,
  118.           class ElementOps, class Implementation>
  119. TStream&
  120. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  121. operator>>= (TStream& toWhere) const
  122. { return (ivElementOps >>= toWhere);
  123. }
  124.  
  125. template <class Element, class Key,
  126.           class ElementOps, class Implementation>
  127. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  128. operator ISequenceAsListImpl& ()
  129. { return *(ISequenceAsListImpl*)ivBase;
  130. }
  131.  
  132. template <class Element, class Key,
  133.           class ElementOps, class Implementation>
  134. IKeySortedSetAsListOps <Element, Key, ElementOps, Implementation>::
  135. operator Implementation* ()
  136. { ivImpl.CheckPointer (this);
  137.   return &ivImpl;
  138. }
  139.  
  140. #pragma info (restore)
  141. #pragma pack ()
  142.