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

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