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

  1. /* Copyright (c) IBM Corp. 1992 */
  2.  
  3. #ifndef _ISTKSEQ_H
  4. #define _ISTKSEQ_H
  5.  
  6. #include <iglobals.h>
  7. #include <icursor.h>
  8.  
  9. template < class Element, class ElementOps, class Base >
  10. class IWStackOnSeq {
  11.   Base ivBase;
  12.   class Cursor;
  13.   friend class Cursor;
  14. public:
  15.  
  16.   class Cursor : public Base::Cursor {
  17.   public:
  18.     Cursor (IWStackOnSeq < Element, ElementOps, Base > const& c)
  19.     : Base::Cursor (c.ivBase) {}
  20.   };
  21.  
  22.                   IWStackOnSeq             (INumber
  23.                                                numberOfElements = 100,
  24.                                                IBoundIndicator =
  25.                                                IUnbounded);
  26.  
  27.                   IWStackOnSeq             (IWStackOnSeq < Element, ElementOps, Base > const&);
  28.  
  29.    IWStackOnSeq < Element, ElementOps, Base >&    operator =                  (IWStackOnSeq < Element, ElementOps, Base > const&);
  30.  
  31.                  ~IWStackOnSeq             ();
  32.  
  33.    Boolean        add                         (Element const&);
  34.  
  35.    Boolean        add                         (Element const&,
  36.                                                ICursor&);
  37.  
  38.    void           addAllFrom                  (IWStackOnSeq < Element, 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.    void           removeLast                  ();
  88.  
  89.    void           removeAtPosition            (IPosition);
  90.  
  91.    Element const& firstElement                () const;
  92.  
  93.    Element const& lastElement                 () const;
  94.  
  95.    Element const& elementAtPosition           (IPosition) const;
  96.  
  97.    Boolean        setToLast                   (ICursor&) const;
  98.  
  99.    Boolean        setToPrevious               (ICursor&) const;
  100.  
  101.    void           setToPosition               (IPosition,
  102.                                                ICursor&) const;
  103.  
  104.    Boolean        isFirst                     (ICursor const&) const;
  105.  
  106.    Boolean        isLast                      (ICursor const&) const;
  107.  
  108.    long           compare                     (IWStackOnSeq < Element, ElementOps, Base > const&,
  109.                                                long (*comparisonFunction)
  110.                                                   (Element const&,
  111.                                                   Element const&)) const;
  112.  
  113.    void           addAsLast                   (Element const&);
  114.  
  115.    void           addAsLast                   (Element const&,
  116.                                                ICursor&);
  117.  
  118.    void           addAsNext                   (Element const&,
  119.                                                ICursor&);
  120.  
  121.    void           addAsPrevious               (Element const&,
  122.                                                ICursor&);
  123.  
  124.    void           addAtPosition               (IPosition,
  125.                                                Element const&);
  126.  
  127.    void           addAtPosition               (IPosition,
  128.                                                Element const&,
  129.                                                ICursor&);
  130.  
  131.    void           sort                        (long (*comparisonFunction)
  132.                                                (Element const&,
  133.                                                Element const&));
  134.  
  135.    void           push                        (Element const&);
  136.  
  137.    void           push                        (Element const&,
  138.                                                ICursor&);
  139.  
  140.    void           pop                         ();
  141.  
  142.    void           pop                         (Element&);
  143.  
  144.    Element const& top                         () const;
  145.  
  146. };
  147.  
  148. #define IDefineGStackOnGSequence(GSeq, GStack) \
  149. template < class Element, class ElementOps > \
  150. class GStack : \
  151.   public IWStackOnSeq < Element, ElementOps, GSeq < Element, ElementOps > > { \
  152. public: \
  153.   GStack (INumber n = 100, IBoundIndicator b = IUnbounded) : \
  154.     IWStackOnSeq < Element, ElementOps, \
  155.            GSeq < Element, ElementOps > > (n, b) {} \
  156. };
  157.  
  158. #include <istkseq.if>
  159.  
  160. #endif
  161.