home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IKSSSEQ.H < prev    next >
Text File  |  1993-09-22  |  7KB  |  190 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 _IKSSSEQ_H
  13. #define _IKSSSEQ_H
  14.  
  15. #include <iglobals.h>
  16. #include <icursor.h>
  17.  
  18. template < class Element, class Key, class ElementOps, class Base >
  19. class IWKSSetOnSeq {
  20.   Base ivBase;
  21.   class Cursor;
  22.   friend class Cursor;
  23. public:
  24.  
  25.   class Cursor : public Base::Cursor {
  26.   protected:
  27.     IBoolean isFor (IWKSSetOnSeq
  28.                      < Element, Key, ElementOps, Base > const& c) const
  29.     { return Base::Cursor::isFor (c.ivBase); }
  30.   public:
  31.     Cursor (IWKSSetOnSeq < Element, Key, ElementOps, Base > const& c)
  32.     : Base::Cursor (c.ivBase) {}
  33.   };
  34.  
  35.                   IWKSSetOnSeq             (INumber
  36.                                                numberOfElements = 100);
  37.  
  38.                   IWKSSetOnSeq             (IWKSSetOnSeq < Element, Key, ElementOps, Base > const&);
  39.  
  40.    IWKSSetOnSeq < Element, Key, ElementOps, Base >&
  41.                   operator =                  (IWKSSetOnSeq < Element, Key, ElementOps, Base > const&);
  42.  
  43.                  ~IWKSSetOnSeq             ();
  44.  
  45.    IBoolean       add                         (Element const&);
  46.  
  47.    IBoolean       add                         (Element const&,
  48.                                                ICursor&);
  49.  
  50.    void           addAllFrom                  (IWKSSetOnSeq < 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         (IWKSSetOnSeq < 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.    void           removeFirst                 ();
  132.  
  133.    void           removeLast                  ();
  134.  
  135.    void           removeAtPosition            (IPosition);
  136.  
  137.    Element const& firstElement                () const;
  138.  
  139.    Element const& lastElement                 () const;
  140.  
  141.    Element const& elementAtPosition           (IPosition) const;
  142.  
  143.    IBoolean       setToLast                   (ICursor&) const;
  144.  
  145.    IBoolean       setToPrevious               (ICursor&) const;
  146.  
  147.    void           setToPosition               (IPosition,
  148.                                                ICursor&) const;
  149.  
  150.    IBoolean       isFirst                     (ICursor const&) const;
  151.  
  152.    IBoolean       isLast                      (ICursor const&) const;
  153.  
  154.    long           compare                     (IWKSSetOnSeq < Element, Key, ElementOps, Base > const&,
  155.                                                long (*comparisonFunction)
  156.                                                   (Element const&,
  157.                                                   Element const&)) const;
  158.  
  159. protected:
  160.  
  161.   IBoolean         locateKey      (Key const&, ICursor&) const;
  162.  
  163.   static ElementOps elementOps ()
  164.   { ElementOps ops;
  165.     return ops;
  166.   }
  167.  
  168. };
  169.  
  170. #define IDefineGKeySortedSetOnGSequence(GSeq, GKSSet) \
  171. template < class Element, class Key, class ElementOps > \
  172. class GKSSet : \
  173.   public IWKSSetOnSeq < Element, Key, ElementOps, \
  174.                         GSeq < Element, ElementOps > > { \
  175. public: \
  176.   GKSSet (INumber n = 100) : \
  177.     IWKSSetOnSeq < Element, Key, ElementOps, \
  178.                    GSeq < Element, ElementOps > > (n) {} \
  179. };
  180.  
  181. #include <ikssseq.if>
  182.  
  183. #ifdef __IBMCPP__
  184. #ifndef __TEMPINC__
  185. #include <ikssseq.c>
  186. #endif
  187. #endif
  188.  
  189. #endif
  190.