home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / ISMKSS.H < prev    next >
Text File  |  1993-09-22  |  9KB  |  226 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 _ISMKSS_H
  13. #define _ISMKSS_H
  14.  
  15. #include <iglobals.h>
  16. #include <icursor.h>
  17.  
  18. template < class Element, class Key, class ElementOps, class Base >
  19. class IWSrtMapOnKSSet {
  20.   Base ivBase;
  21.   class Cursor;
  22.   friend class Cursor;
  23. public:
  24.  
  25.   class Cursor : public Base::Cursor {
  26.   protected:
  27.     IBoolean isFor (IWSrtMapOnKSSet
  28.                      < Element, Key, ElementOps, Base >const& c) const
  29.     { return Base::Cursor::isFor (c.ivBase); }
  30.   public:
  31.     Cursor (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const& c)
  32.     : Base::Cursor (c.ivBase) {}
  33.   };
  34.  
  35.                   IWSrtMapOnKSSet             (INumber
  36.                                                numberOfElements = 100);
  37.  
  38.                   IWSrtMapOnKSSet             (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  39.  
  40.    IWSrtMapOnKSSet < Element, Key, ElementOps, Base >&
  41.                   operator =                  (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  42.  
  43.                  ~IWSrtMapOnKSSet             ();
  44.  
  45.    IBoolean       add                         (Element const&);
  46.  
  47.    IBoolean       add                         (Element const&,
  48.                                                ICursor&);
  49.  
  50.    void           addAllFrom                  (IWSrtMapOnKSSet < 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             (IWSrtMapOnKSSet < 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 ==                 (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&) const;
  116.  
  117.    IBoolean       operator !=                 (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&) const;
  118.  
  119.    void           unionWith                   (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  120.  
  121.    void           intersectionWith            (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  122.  
  123.    void           differenceWith              (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  124.  
  125.    void           addUnion                    (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&,
  126.                                                IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  127.  
  128.    void           addIntersection             (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&,
  129.                                                IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  130.  
  131.    void           addDifference               (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&,
  132.                                                IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&);
  133.  
  134.    Key const&     key                         (Element const&) const;
  135.  
  136.    IBoolean       containsElementWithKey      (Key const&) const;
  137.  
  138.    IBoolean       containsAllKeysFrom         (IWSrtMapOnKSSet < 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.    void           removeFirst                 ();
  165.  
  166.    void           removeLast                  ();
  167.  
  168.    void           removeAtPosition            (IPosition);
  169.  
  170.    Element const& firstElement                () const;
  171.  
  172.    Element const& lastElement                 () const;
  173.  
  174.    Element const& elementAtPosition           (IPosition) const;
  175.  
  176.    IBoolean       setToLast                   (ICursor&) const;
  177.  
  178.    IBoolean       setToPrevious               (ICursor&) const;
  179.  
  180.    void           setToPosition               (IPosition,
  181.                                                ICursor&) const;
  182.  
  183.    IBoolean       isFirst                     (ICursor const&) const;
  184.  
  185.    IBoolean       isLast                      (ICursor const&) const;
  186.  
  187.    long           compare                     (IWSrtMapOnKSSet < Element, Key, ElementOps, Base > const&,
  188.                                                long (*comparisonFunction)
  189.                                                   (Element const&,
  190.                                                   Element const&)) const;
  191.  
  192. protected:
  193.  
  194.   static IBoolean  isContained    (Element const&, void* env);
  195.   static IBoolean  isNotContained (Element const&, void* env);
  196.  
  197.   static ElementOps elementOps ()
  198.   { ElementOps ops;
  199.     return ops;
  200.   }
  201.  
  202. };
  203.  
  204. #define IDefineGSortedMapOnGKeySortedSet(GKSSet, GSrtMap) \
  205. template < class Element, class Key, class ElementOps > \
  206. class GSrtMap : \
  207.   public IWSrtMapOnKSSet \
  208.            < Element, Key, ElementOps, \
  209.              GKSSet < Element, Key, ElementOps > > { \
  210. public: \
  211.   GSrtMap (INumber n = 100) : \
  212.     IWSrtMapOnKSSet \
  213.       < Element, Key, ElementOps, \
  214.         GKSSet < Element, Key, ElementOps > > (n) {} \
  215. };
  216.  
  217. #include <ismkss.if>
  218.  
  219. #ifdef __IBMCPP__
  220. #ifndef __TEMPINC__
  221. #include <ismkss.c>
  222. #endif
  223. #endif
  224.  
  225. #endif
  226.