home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / bbxxk / imapks.h__ / IMAPKS.H
Encoding:
C/C++ Source or Header  |  1992-10-26  |  6.7 KB  |  180 lines

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