home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IPQUKSB.H < prev    next >
Text File  |  1993-09-22  |  6KB  |  158 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 _IPQUKSB_H
  13. #define _IPQUKSB_H
  14.  
  15. #include <iglobals.h>
  16. #include <icursor.h>
  17.  
  18. template < class Element, class Key, class ElementOps, class Base >
  19. class IWPQueOnKSBag {
  20.   Base ivBase;
  21.   class Cursor;
  22.   friend class Cursor;
  23. public:
  24.  
  25.   class Cursor : public Base::Cursor {
  26.   protected:
  27.     IBoolean isFor (IWPQueOnKSBag
  28.                      < Element, Key, ElementOps, Base > const& c) const
  29.     { return Base::Cursor::isFor (c.ivBase); }
  30.   public:
  31.     Cursor (IWPQueOnKSBag < Element, Key, ElementOps, Base > const& c)
  32.     : Base::Cursor (c.ivBase) {}
  33.   };
  34.  
  35.                   IWPQueOnKSBag             (INumber
  36.                                                numberOfElements = 100);
  37.  
  38.                   IWPQueOnKSBag             (IWPQueOnKSBag < Element, Key, ElementOps, Base > const&);
  39.  
  40.    IWPQueOnKSBag < Element, Key, ElementOps, Base >&
  41.                   operator =                  (IWPQueOnKSBag < Element, Key, ElementOps, Base > const&);
  42.  
  43.                  ~IWPQueOnKSBag             ();
  44.  
  45.    IBoolean       add                         (Element const&);
  46.  
  47.    IBoolean       add                         (Element const&,
  48.                                                ICursor&);
  49.  
  50.    void           addAllFrom                  (IWPQueOnKSBag < Element, Key, ElementOps, Base > const&);
  51.  
  52.    Element const& elementAt                   (ICursor const&) const;
  53.  
  54.    Element const& anyElement                  () const;
  55.  
  56.    void           removeAll                   ();
  57.  
  58.    IBoolean       isBounded                   () const;
  59.  
  60.    INumber        maxNumberOfElements         () const;
  61.  
  62.    INumber        numberOfElements            () const;
  63.  
  64.    IBoolean       isEmpty                     () const;
  65.  
  66.    IBoolean       isFull                      () const;
  67.  
  68.    ICursor*       newCursor                   () const;
  69.  
  70.    IBoolean       setToFirst                  (ICursor&) const;
  71.  
  72.    IBoolean       setToNext                   (ICursor&) const;
  73.  
  74.    IBoolean       allElementsDo               (IBoolean (*function)
  75.                                                (Element const&, void*),
  76.                                                void* additionalArgument = 0)
  77.                                                const;
  78.  
  79.    IBoolean       allElementsDo               (IConstantIterator
  80.                                                   <Element>&) const;
  81.  
  82.    IBoolean       isConsistent                () const;
  83.  
  84.    Key const&     key                         (Element const&) const;
  85.  
  86.    IBoolean       containsElementWithKey      (Key const&) const;
  87.  
  88.    IBoolean       containsAllKeysFrom         (IWPQueOnKSBag < Element, Key, ElementOps, Base > const&) const;
  89.  
  90.    IBoolean       locateElementWithKey        (Key const&, ICursor&)
  91.                                                const;
  92.  
  93.    IBoolean       locateOrAddElementWithKey   (Element const&);
  94.  
  95.    IBoolean       locateOrAddElementWithKey   (Element const&,
  96.                                                ICursor&);
  97.  
  98.    Element const& elementWithKey              (Key const&) const;
  99.  
  100.    INumber        numberOfElementsWithKey     (Key const&) const;
  101.  
  102.    IBoolean       locateNextElementWithKey    (Key const&,
  103.                                                ICursor&) const;
  104.  
  105.    INumber        numberOfDifferentKeys       () const;
  106.  
  107.    IBoolean       setToNextWithDifferentKey   (ICursor&) const;
  108.  
  109.    void           removeFirst                 ();
  110.  
  111.    Element const& firstElement                () const;
  112.  
  113.    Element const& lastElement                 () const;
  114.  
  115.    Element const& elementAtPosition           (IPosition) const;
  116.  
  117.    IBoolean       setToLast                   (ICursor&) const;
  118.  
  119.    IBoolean       setToPrevious               (ICursor&) const;
  120.  
  121.    void           setToPosition               (IPosition,
  122.                                                ICursor&) const;
  123.  
  124.    IBoolean       isFirst                     (ICursor const&) const;
  125.  
  126.    IBoolean       isLast                      (ICursor const&) const;
  127.  
  128.    long           compare                     (IWPQueOnKSBag < Element, Key, ElementOps, Base > const&,
  129.                                                long (*comparisonFunction)
  130.                                                   (Element const&,
  131.                                                   Element const&)) const;
  132.  
  133.    void           enqueue                     (Element const&);
  134.  
  135.    void           enqueue                     (Element const&,
  136.                                                ICursor&);
  137.  
  138.    void           dequeue                     ();
  139.  
  140.    void           dequeue                     (Element&);
  141.  
  142. };
  143.  
  144. #define IDefineGPriorityQueueOnGKeySortedBag(GKSBag, GPrioQue) \
  145. template < class Element, class Key, class ElementOps > \
  146. class GPrioQue : \
  147.   public IWPQueOnKSBag < Element, Key, \
  148.                             ElementOps, GKSBag < Element, Key, ElementOps > > { \
  149. public: \
  150.   GPrioQue (INumber n = 100) : \
  151.     IWPQueOnKSBag < Element, Key, ElementOps, \
  152.                        GKSBag < Element, Key, ElementOps > > (n) {} \
  153. };
  154.  
  155. #include <ipquksb.if>
  156.  
  157. #endif
  158.