home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IILNSEQ.H < prev    next >
Text File  |  1993-09-22  |  5KB  |  136 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 _IILNSEQ_H
  13. #define _IILNSEQ_H
  14.  
  15. #include <iglobals.h>
  16. #include <icursor.h>
  17.  
  18. class ILinkedSequenceImpl
  19. {
  20. public:
  21.   class Node
  22.   {
  23.   protected:
  24.     friend class ILinkedSequenceImpl;
  25.  
  26.     Node* ivNext;
  27.     Node* ivPrevious;
  28.   };
  29.  
  30.   class Operations
  31.   {
  32.     virtual Node*       newNode              (void const* node) const = 0;
  33.     virtual void        deleteNode           (void* node) const = 0;
  34.  
  35.     virtual IBoolean     constantFunctionIteration
  36.                                              (void *function,
  37.                                               void* env,
  38.                                               void const* node) = 0;
  39.     virtual IBoolean     functionIteration    (void *function,
  40.                                               void* env,
  41.                                               void* node) = 0;
  42.     virtual IBoolean     constantIteratorIteration
  43.                                              (void* iterator,
  44.                                               void const* node) = 0;
  45.     virtual IBoolean     iteratorIteration    (void* iterator,
  46.                                               void* node) = 0;
  47.  
  48.     virtual long        functionComparison   (void *compareFunction,
  49.                                               void const* node1,
  50.                                               void const* node2) = 0;
  51.  
  52.     friend class ILinkedSequenceImpl;
  53.   };
  54.  
  55. private :
  56.  
  57.   Node *ivFirst;
  58.   Node *ivLast;
  59.   INumber ivNumberOfElements;
  60.   Operations *ivOps;
  61.  
  62.  
  63. public :
  64.  
  65.                   ILinkedSequenceImpl         (Operations*);
  66.  
  67.                   ILinkedSequenceImpl         (ILinkedSequenceImpl const&,
  68.                                                Operations*);
  69.  
  70.                  ~ILinkedSequenceImpl         ();
  71.  
  72.    void           addAllFrom                  (ILinkedSequenceImpl const&);
  73.  
  74.    void           removeAt                    (Node*);
  75.  
  76.    INumber        removeAll                   (void* predicate,
  77.                                                void* environment);
  78.  
  79.    void           removeAll                   ();
  80.  
  81.    INumber        numberOfElements            () const;
  82.  
  83.    IBoolean        isEmpty                     () const;
  84.  
  85.    IBoolean        isFull                      () const;
  86.  
  87.    IBoolean        setToFirst                  (Node*&) const;
  88.  
  89.    IBoolean        setToNext                   (Node*&) const;
  90.  
  91.    IBoolean        allElementsDo               (void* function, void* env);
  92.  
  93.    IBoolean        allElementsDo               (void* function, void* env) const;
  94.  
  95.    IBoolean        allElementsDo               (void* iterator);
  96.  
  97.    IBoolean        allElementsDo               (void* iterator) const;
  98.  
  99.    void           removeFirst                 ();
  100.  
  101.    void           removeLast                  ();
  102.  
  103.    void           removeAtPosition            (IPosition);
  104.  
  105.    IBoolean        setToLast                   (Node*&) const;
  106.  
  107.    IBoolean        setToPrevious               (Node*&) const;
  108.  
  109.    void           setToPosition               (IPosition, Node*&) const;
  110.  
  111.    IBoolean        isFirst                     (Node const*) const;
  112.  
  113.    IBoolean        isLast                      (Node const*) const;
  114.  
  115.    long           compare                     (ILinkedSequenceImpl const&,
  116.                                                void* comparisonFunction) const;
  117.  
  118.    Node*          addAsFirst                  (Node*);
  119.  
  120.    Node*          addAsLast                   (Node*);
  121.  
  122.    Node*          addAsNext                   (Node*, Node*);
  123.  
  124.    Node*          addAsPrevious               (Node*, Node*);
  125.  
  126.    Node*          addAtPosition               (IPosition, Node*);
  127.  
  128.    void           sort                        (void* comparisonFunction);
  129.  
  130.    IBoolean        checkNode                   (Node const*) const;
  131.  
  132.    IBoolean        isConsistent                () const;
  133. };
  134.  
  135. #endif
  136.