home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IKSKSS.H < prev    next >
Text File  |  1993-09-22  |  6KB  |  149 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 _IKSKSS_H
  13. #define _IKSKSS_H
  14.  
  15. #include <iglobals.h>
  16. #include <icursor.h>
  17.  
  18. template < class Element, class Key, class ElementOps, class Base >
  19. class IWKeySetOnKSSet {
  20.   Base ivBase;
  21.   class Cursor;
  22.   friend class Cursor;
  23. public:
  24.  
  25.   class Cursor : public Base::Cursor {
  26.   protected:
  27.     IBoolean isFor (IWKeySetOnKSSet
  28.                      < Element, Key, ElementOps, Base >const& c) const
  29.     { return Base::Cursor::isFor (c.ivBase); }
  30.   public:
  31.     Cursor (IWKeySetOnKSSet < Element, Key, ElementOps, Base > const& c)
  32.     : Base::Cursor (c.ivBase) {}
  33.   };
  34.  
  35.                   IWKeySetOnKSSet             (INumber
  36.                                                numberOfElements = 100);
  37.  
  38.                   IWKeySetOnKSSet             (IWKeySetOnKSSet < Element, Key, ElementOps, Base > const&);
  39.  
  40.    IWKeySetOnKSSet < Element, Key, ElementOps, Base >&
  41.                   operator =                  (IWKeySetOnKSSet < Element, Key, ElementOps, Base > const&);
  42.  
  43.                  ~IWKeySetOnKSSet             ();
  44.  
  45.    IBoolean       add                         (Element const&);
  46.  
  47.    IBoolean       add                         (Element const&,
  48.                                                ICursor&);
  49.  
  50.    void           addAllFrom                  (IWKeySetOnKSSet < 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.    Key const&     key                         (Element const&) const;
  102.  
  103.    IBoolean       containsElementWithKey      (Key const&) const;
  104.  
  105.    IBoolean       containsAllKeysFrom         (IWKeySetOnKSSet < Element, Key, ElementOps, Base > const&) const;
  106.  
  107.    IBoolean       locateElementWithKey        (Key const&, ICursor&)
  108.                                                const;
  109.  
  110.    IBoolean       replaceElementWithKey       (Element const&);
  111.  
  112.    IBoolean       replaceElementWithKey       (Element const&,
  113.                                                ICursor&);
  114.  
  115.    IBoolean       locateOrAddElementWithKey   (Element const&);
  116.  
  117.    IBoolean       locateOrAddElementWithKey   (Element const&,
  118.                                                ICursor&);
  119.  
  120.    IBoolean       addOrReplaceElementWithKey  (Element const&);
  121.  
  122.    IBoolean       addOrReplaceElementWithKey  (Element const&,
  123.                                                ICursor&);
  124.  
  125.    IBoolean       removeElementWithKey        (Key const&);
  126.  
  127.    Element const& elementWithKey              (Key const&) const;
  128.  
  129.    Element&       elementWithKey              (Key const&);
  130.  
  131. };
  132.  
  133. #define IDefineGKeySetOnGKeySortedSet(GKSSet, GKeySet) \
  134. template < class Element, class Key, class ElementOps > \
  135. class GKeySet : \
  136.   public IWKeySetOnKSSet \
  137.            < Element, Key, ElementOps, \
  138.              GKSSet < Element, Key, ElementOps > > { \
  139. public: \
  140.   GKeySet (INumber n = 100) : \
  141.     IWKeySetOnKSSet \
  142.       < Element, Key, ElementOps, \
  143.         GKSSet < Element, Key, ElementOps > > (n) {} \
  144. };
  145.  
  146. #include <ikskss.if>
  147.  
  148. #endif
  149.