home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IESSEQ.H < prev    next >
Text File  |  1993-09-22  |  9KB  |  223 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 _IESSEQ_H
  13. #define _IESSEQ_H
  14.  
  15. #include <iglobals.h>
  16. #include <icursor.h>
  17.  
  18. template < class Element, class ElementOps, class Base >
  19. class IWEqSeqOnSeq {
  20.   Base ivBase;
  21.   class Cursor;
  22.   friend class Cursor;
  23. public:
  24.  
  25.   class Cursor : public Base::Cursor {
  26.   protected:
  27.     IBoolean isFor (IWEqSeqOnSeq < Element, ElementOps, Base > const& c) const
  28.     { return Base::Cursor::isFor (c.ivBase); }
  29.  
  30.   public:
  31.     Cursor (IWEqSeqOnSeq < Element, ElementOps, Base > const& c)
  32.     : Base::Cursor (c.ivBase) {}
  33.   };
  34.  
  35.                   IWEqSeqOnSeq             (INumber
  36.                                                numberOfElements = 100);
  37.  
  38.                   IWEqSeqOnSeq             (IWEqSeqOnSeq < Element, ElementOps, Base > const&);
  39.  
  40.    IWEqSeqOnSeq < Element, ElementOps, Base >&
  41.                   operator =                  (IWEqSeqOnSeq < Element, ElementOps, Base > const&);
  42.  
  43.                  ~IWEqSeqOnSeq             ();
  44.  
  45.    IBoolean       add                         (Element const&);
  46.  
  47.    IBoolean       add                         (Element const&,
  48.                                                ICursor&);
  49.  
  50.    void           addAllFrom                  (IWEqSeqOnSeq < Element, ElementOps, Base > const&);
  51.  
  52.    Element const& elementAt                   (ICursor const&) const;
  53.  
  54.    Element&       elementAt                   (ICursor const&);
  55.  
  56.    Element const& anyElement                  () const;
  57.  
  58.    void           removeAt                    (ICursor const&);
  59.  
  60.    INumber        removeAll                   (IBoolean (*property)
  61.                                                (Element const&, void*),
  62.                                                void* additionalArgument = 0);
  63.  
  64.    void           replaceAt                   (ICursor const&,
  65.                                                Element const&);
  66.  
  67.    void           removeAll                   ();
  68.  
  69.    IBoolean       isBounded                   () const;
  70.  
  71.    INumber        maxNumberOfElements         () const;
  72.  
  73.    INumber        numberOfElements            () const;
  74.  
  75.    IBoolean       isEmpty                     () const;
  76.  
  77.    IBoolean       isFull                      () const;
  78.  
  79.    ICursor*       newCursor                   () const;
  80.  
  81.    IBoolean       setToFirst                  (ICursor&) const;
  82.  
  83.    IBoolean       setToNext                   (ICursor&) const;
  84.  
  85.    IBoolean       allElementsDo               (IBoolean (*function)
  86.                                                   (Element&, void*),
  87.                                                void* additionalArgument = 0);
  88.  
  89.    IBoolean       allElementsDo               (IIterator <Element>&);
  90.  
  91.    IBoolean       allElementsDo               (IBoolean (*function)
  92.                                                (Element const&, void*),
  93.                                                void* additionalArgument = 0)
  94.                                                const;
  95.  
  96.    IBoolean       allElementsDo               (IConstantIterator
  97.                                                   <Element>&) const;
  98.  
  99.    IBoolean       isConsistent                () const;
  100.  
  101.    IBoolean       contains                    (Element const&) const;
  102.  
  103.    IBoolean       containsAllFrom             (IWEqSeqOnSeq < Element, ElementOps, Base > const&) const;
  104.  
  105.    IBoolean       locate                      (Element const&, ICursor&)
  106.                                                const;
  107.  
  108.    IBoolean       locateOrAdd                 (Element const&);
  109.  
  110.    IBoolean       locateOrAdd                 (Element const&,
  111.                                                ICursor&);
  112.  
  113.    IBoolean       remove                      (Element const&);
  114.  
  115.    INumber        numberOfOccurrences         (Element const&) const;
  116.  
  117.    IBoolean       locateNext                  (Element const&, ICursor&)
  118.                                                const;
  119.  
  120.    INumber        removeAllOccurrences        (Element const&);
  121.  
  122.    IBoolean       operator ==                 (IWEqSeqOnSeq < Element, ElementOps, Base > const&) const;
  123.  
  124.    IBoolean       operator !=                 (IWEqSeqOnSeq < Element, ElementOps, Base > const&) const;
  125.  
  126.    void           removeFirst                 ();
  127.  
  128.    void           removeLast                  ();
  129.  
  130.    void           removeAtPosition            (IPosition);
  131.  
  132.    Element const& firstElement                () const;
  133.  
  134.    Element const& lastElement                 () const;
  135.  
  136.    Element const& elementAtPosition           (IPosition) const;
  137.  
  138.    IBoolean       setToLast                   (ICursor&) const;
  139.  
  140.    IBoolean       setToPrevious               (ICursor&) const;
  141.  
  142.    void           setToPosition               (IPosition,
  143.                                                ICursor&) const;
  144.  
  145.    IBoolean       isFirst                     (ICursor const&) const;
  146.  
  147.    IBoolean       isLast                      (ICursor const&) const;
  148.  
  149.    long           compare                     (IWEqSeqOnSeq < Element, ElementOps, Base > const&,
  150.                                                long (*comparisonFunction)
  151.                                                   (Element const&,
  152.                                                   Element const&)) const;
  153.  
  154.    void           addAsFirst                  (Element const&);
  155.  
  156.    void           addAsFirst                  (Element const&,
  157.                                                ICursor&);
  158.  
  159.    void           addAsLast                   (Element const&);
  160.  
  161.    void           addAsLast                   (Element const&,
  162.                                                ICursor&);
  163.  
  164.    void           addAsNext                   (Element const&,
  165.                                                ICursor&);
  166.  
  167.    void           addAsPrevious               (Element const&,
  168.                                                ICursor&);
  169.  
  170.    void           addAtPosition               (IPosition,
  171.                                                Element const&);
  172.  
  173.    void           addAtPosition               (IPosition,
  174.                                                Element const&,
  175.                                                ICursor&);
  176.  
  177.    void           sort                        (long (*comparisonFunction)
  178.                                                (Element const&,
  179.                                                Element const&));
  180.  
  181.    IBoolean       locateFirst                 (Element const&, ICursor&)
  182.                                                const;
  183.  
  184.    IBoolean       locateLast                  (Element const&,
  185.                                                ICursor&) const;
  186.  
  187.    IBoolean       locatePrevious              (Element const&,
  188.                                                ICursor&) const;
  189.  
  190. protected:
  191.  
  192.   static IBoolean  isContained    (Element const&, void* env);
  193.   static IBoolean  isNotContained (Element const&, void* env);
  194.   static IBoolean  isEqual        (Element const&, void* env);
  195.  
  196.   static ElementOps elementOps ()
  197.   { ElementOps ops;
  198.     return ops;
  199.   }
  200.  
  201. };
  202.  
  203. #define IDefineGEqualitySequenceOnGSequence(GSeq, GEqSeq) \
  204. template < class Element, class ElementOps > \
  205. class GEqSeq : \
  206.   public IWEqSeqOnSeq < Element, ElementOps, \
  207.                         GSeq < Element, ElementOps > > { \
  208. public: \
  209.   GEqSeq (INumber n = 100) : \
  210.     IWEqSeqOnSeq < Element, ElementOps, \
  211.                    GSeq < Element, ElementOps > > (n) {} \
  212. };
  213.  
  214. #include <iesseq.if>
  215.  
  216. #ifdef __IBMCPP__
  217. #ifndef __TEMPINC__
  218. #include <iesseq.c>
  219. #endif
  220. #endif
  221.  
  222. #endif
  223.