home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / runnable / ibmc / ibmclass / iksbseq.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-26  |  6.4 KB  |  184 lines

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