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