home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / bbxxj / iheapseq.h__ / IHEAPSEQ.H
Encoding:
C/C++ Source or Header  |  1992-10-26  |  3.5 KB  |  104 lines

  1. /* Copyright (c) IBM Corp. 1992 */
  2.  
  3. #ifndef _IHEAPSEQ_H
  4. #define _IHEAPSEQ_H
  5.  
  6. #include <iglobals.h>
  7. #include <icursor.h>
  8.  
  9. template < class Element, class ElementOps, class Base >
  10. class IWHeapOnSeq {
  11.   Base ivBase;
  12.   class Cursor;
  13.   friend class Cursor;
  14. public:
  15.  
  16.   class Cursor : public Base::Cursor {
  17.   public:
  18.     Cursor (IWHeapOnSeq
  19.           < Element, ElementOps, Base > const& c)
  20.     : Base::Cursor (c.ivBase) {}
  21.   };
  22.  
  23.                   IWHeapOnSeq             (INumber
  24.                                                numberOfElements = 100,
  25.                                                IBoundIndicator =
  26.                                                IUnbounded);
  27.  
  28.                   IWHeapOnSeq             (IWHeapOnSeq < Element, ElementOps, Base > const&);
  29.  
  30.    IWHeapOnSeq < Element, ElementOps, Base >&    operator =                  (IWHeapOnSeq < Element, ElementOps, Base > const&);
  31.  
  32.                  ~IWHeapOnSeq             ();
  33.  
  34.    Boolean        add                         (Element const&);
  35.  
  36.    Boolean        add                         (Element const&,
  37.                                                ICursor&);
  38.  
  39.    void           addAllFrom                  (IWHeapOnSeq < Element, ElementOps, Base > const&);
  40.  
  41.    Element const& elementAt                   (ICursor const&) const;
  42.  
  43.    Element&       elementAt                   (ICursor const&);
  44.  
  45.    Element const& anyElement                  () const;
  46.  
  47.    void           removeAt                    (ICursor const&);
  48.  
  49.    INumber        removeAll                   (Boolean (*property)
  50.                                                (Element const&, void*),
  51.                                                void* additionalArgument = 0);
  52.  
  53.    void           replaceAt                   (ICursor const&,
  54.                                                Element const&);
  55.  
  56.    void           removeAll                   ();
  57.  
  58.    Boolean        isBounded                   () const;
  59.  
  60.    INumber        maxNumberOfElements         () const;
  61.  
  62.    INumber        numberOfElements            () const;
  63.  
  64.    Boolean        isEmpty                     () const;
  65.  
  66.    Boolean        isFull                      () const;
  67.  
  68.    ICursor*       newCursor                   () const;
  69.  
  70.    Boolean        setToFirst                  (ICursor&) const;
  71.  
  72.    Boolean        setToNext                   (ICursor&) const;
  73.  
  74.    Boolean        allElementsDo               (Boolean (*function)
  75.                                                   (Element&, void*),
  76.                                                void* additionalArgument = 0);
  77.  
  78.    Boolean        allElementsDo               (IIterator <Element>&);
  79.  
  80.    Boolean        allElementsDo               (Boolean (*function)
  81.                                                (Element const&, void*),
  82.                                                void* additionalArgument = 0)
  83.                                                const;
  84.  
  85.    Boolean        allElementsDo               (IConstantIterator
  86.                                                   <Element>&) const;
  87.  
  88. };
  89.  
  90. #define IDefineGHeapOnGSequence(GSeq, GHeap) \
  91. template < class Element, class ElementOps > \
  92. class GHeap : \
  93.   public IWHeapOnSeq < Element, ElementOps, \
  94.                GSeq < Element, ElementOps > > { \
  95. public: \
  96.   GHeap (INumber n = 100, IBoundIndicator b = IUnbounded) : \
  97.     IWHeapOnSeq < Element, ElementOps, \
  98.           GSeq < Element, ElementOps > > (n, b) {} \
  99. };
  100.  
  101. #include <iheapseq.if>
  102.  
  103. #endif
  104.