home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IMAPKS.H < prev    next >
Text File  |  1993-09-22  |  8KB  |  198 lines

  1. /*******************************************************************************
  2. *                                                                              *
  3. * COPYRIGHT:                                                                   *
  4. *   IBM C/C++ Tools Version 2.01 - Collection Class Library                    *
  5. *   Licensed Materials - Property of IBM                                       *
  6. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  7. *   All Rights Reserved                                                        *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  10. *                                                                              *
  11. *******************************************************************************/
  12. #ifndef _IMAPKS_H
  13. #define _IMAPKS_H
  14.  
  15. #include <iglobals.h>
  16. #include <icursor.h>
  17.  
  18. template < class Element, class Key, class ElementOps, class Base >
  19. class IWMapOnKeySet {
  20.   Base ivBase;
  21.   class Cursor;
  22.   friend class Cursor;
  23. public:
  24.  
  25.   class Cursor : public Base::Cursor {
  26.   protected:
  27.     IBoolean isFor (IWMapOnKeySet
  28.                      < Element, Key, ElementOps, Base > const& c) const
  29.     { return Base::Cursor::isFor (c.ivBase); }
  30.   public:
  31.     Cursor (IWMapOnKeySet < Element, Key, ElementOps, Base > const& c)
  32.     : Base::Cursor (c.ivBase) {}
  33.   };
  34.  
  35.                   IWMapOnKeySet             (INumber
  36.                                                numberOfElements = 100);
  37.  
  38.                   IWMapOnKeySet             (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  39.  
  40.    IWMapOnKeySet < Element, Key, ElementOps, Base >&
  41.                   operator =                  (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  42.  
  43.                  ~IWMapOnKeySet             ();
  44.  
  45.    IBoolean       add                         (Element const&);
  46.  
  47.    IBoolean       add                         (Element const&,
  48.                                                ICursor&);
  49.  
  50.    void           addAllFrom                  (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  51.  
  52.    Element const& elementAt                   (ICursor const&) const;
  53.  
  54.    Element&       elementAt                   (ICursor const&);
  55.  
  56.    Element const& anyElement                  () const;
  57.  
  58.    void           removeAt                    (ICursor const&);
  59.  
  60.    INumber        removeAll                   (IBoolean (*property)
  61.                                                (Element const&, void*),
  62.                                                void* additionalArgument = 0);
  63.  
  64.    void           replaceAt                   (ICursor const&,
  65.                                                Element const&);
  66.  
  67.    void           removeAll                   ();
  68.  
  69.    IBoolean       isBounded                   () const;
  70.  
  71.    INumber        maxNumberOfElements         () const;
  72.  
  73.    INumber        numberOfElements            () const;
  74.  
  75.    IBoolean       isEmpty                     () const;
  76.  
  77.    IBoolean       isFull                      () const;
  78.  
  79.    ICursor*       newCursor                   () const;
  80.  
  81.    IBoolean       setToFirst                  (ICursor&) const;
  82.  
  83.    IBoolean       setToNext                   (ICursor&) const;
  84.  
  85.    IBoolean       allElementsDo               (IBoolean (*function)
  86.                                                   (Element&, void*),
  87.                                                void* additionalArgument = 0);
  88.  
  89.    IBoolean       allElementsDo               (IIterator <Element>&);
  90.  
  91.    IBoolean       allElementsDo               (IBoolean (*function)
  92.                                                (Element const&, void*),
  93.                                                void* additionalArgument = 0)
  94.                                                const;
  95.  
  96.    IBoolean       allElementsDo               (IConstantIterator
  97.                                                   <Element>&) const;
  98.  
  99.    IBoolean       isConsistent                () const;
  100.  
  101.    IBoolean       contains                    (Element const&) const;
  102.  
  103.    IBoolean       containsAllFrom             (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
  104.  
  105.    IBoolean       locate                      (Element const&, ICursor&)
  106.                                                const;
  107.  
  108.    IBoolean       locateOrAdd                 (Element const&);
  109.  
  110.    IBoolean       locateOrAdd                 (Element const&,
  111.                                                ICursor&);
  112.  
  113.    IBoolean       remove                      (Element const&);
  114.  
  115.    IBoolean       operator ==                 (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
  116.  
  117.    IBoolean       operator !=                 (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
  118.  
  119.    void           unionWith                   (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  120.  
  121.    void           intersectionWith            (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  122.  
  123.    void           differenceWith              (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  124.  
  125.    void           addUnion                    (IWMapOnKeySet < Element, Key, ElementOps, Base > const&,
  126.                                                IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  127.  
  128.    void           addIntersection             (IWMapOnKeySet < Element, Key, ElementOps, Base > const&,
  129.                                                IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  130.  
  131.    void           addDifference               (IWMapOnKeySet < Element, Key, ElementOps, Base > const&,
  132.                                                IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
  133.  
  134.    Key const&     key                         (Element const&) const;
  135.  
  136.    IBoolean       containsElementWithKey      (Key const&) const;
  137.  
  138.    IBoolean       containsAllKeysFrom         (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
  139.  
  140.    IBoolean       locateElementWithKey        (Key const&, ICursor&)
  141.                                                const;
  142.  
  143.    IBoolean       replaceElementWithKey       (Element const&);
  144.  
  145.    IBoolean       replaceElementWithKey       (Element const&,
  146.                                                ICursor&);
  147.  
  148.    IBoolean       locateOrAddElementWithKey   (Element const&);
  149.  
  150.    IBoolean       locateOrAddElementWithKey   (Element const&,
  151.                                                ICursor&);
  152.  
  153.    IBoolean       addOrReplaceElementWithKey  (Element const&);
  154.  
  155.    IBoolean       addOrReplaceElementWithKey  (Element const&,
  156.                                                ICursor&);
  157.  
  158.    IBoolean       removeElementWithKey        (Key const&);
  159.  
  160.    Element const& elementWithKey              (Key const&) const;
  161.  
  162.    Element&       elementWithKey              (Key const&);
  163.  
  164. protected:
  165.  
  166.   static IBoolean  isContained    (Element const&, void* env);
  167.   static IBoolean  isNotContained (Element const&, void* env);
  168.  
  169.   static ElementOps elementOps ()
  170.   { ElementOps ops;
  171.     return ops;
  172.   }
  173.  
  174. };
  175.  
  176. #define IDefineGMapOnGKeySet(GKeySet, GMap) \
  177. template < class Element, class Key, class ElementOps > \
  178. class GMap : \
  179.   public IWMapOnKeySet \
  180.            < Element, Key, ElementOps, \
  181.              GKeySet < Element, Key, ElementOps > > { \
  182. public: \
  183.   GMap (INumber n = 100) : \
  184.     IWMapOnKeySet \
  185.       < Element, Key, ElementOps, \
  186.         GKeySet < Element, Key, ElementOps > > (n) {} \
  187. };
  188.  
  189. #include <imapks.if>
  190.  
  191. #ifdef __IBMCPP__
  192. #ifndef __TEMPINC__
  193. #include <imapks.c>
  194. #endif
  195. #endif
  196.  
  197. #endif
  198.