home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / h.z / WCLISTIT.H < prev    next >
C/C++ Source or Header  |  1996-07-24  |  10KB  |  389 lines

  1. //
  2. //  wclistit.h    Defines for the WATCOM Container List Iterator Class
  3. //
  4. //  Copyright by WATCOM International Corp. 1988-1996.  All rights reserved.
  5. //
  6. #ifndef _WCLISTIT_H_INCLUDED
  7. #define _WCLISTIT_H_INCLUDED
  8.  
  9. //
  10. // There are 12 list iterator classes.
  11. //
  12. // WCValSListIter, WCValDListIter, WCPtrSListIter, WCPtrDListIter,
  13. // WCIsvSListIter and WCIsvDListIter iterate only NON-CONSTANT lists.
  14. // For example, to iterate a non-constant WCValSList, use the WCValSListIter
  15. // class.
  16. //
  17. // WCValConstSListIter, WCValConstDListIter, WCPtrConstSListIter,
  18. // WCPtrConstDListIter, WCIsvConstSListIter and WCIsvConstDListIter iterate
  19. // either constant or non-consant lists.  The insert and append member
  20. // functions are private to these iterator classes.
  21. // For example, to iterate a constant WCIsvDList, use the
  22. // WCIsvConstDListIter class.
  23. //
  24.  
  25. #pragma warning 621 9       // I want the behaviour this warning points to
  26.  
  27. #ifndef __cplusplus
  28. #error wclistit.h is for use with C++
  29. #endif
  30.  
  31. #ifndef _WCDEFS_H_INCLUDED
  32.  #include <wcdefs.h>
  33. #endif
  34. #ifndef _WCLIST_H_INCLUDED
  35.  #include <wclist.h>
  36. #endif
  37. #ifndef _WCLIBASE_H_INCLUDED
  38.  #include <wclibase.h>
  39. #endif
  40.  
  41.  
  42.  
  43.  
  44. //
  45. //  This defines an iterator class for non-const single linked list of
  46. //  values.
  47. //
  48. //  The operators --() and -=() and the insert member function are made
  49. //  private to prevent their being used with a single linked list.
  50. //
  51.  
  52. template<class Type>
  53. class WCValSListIter : public WCValListIterBase<Type, WCValSList<Type>,
  54.                                                       WCNIsvSLink<Type> >  {
  55. private:
  56.     int operator--();                                                          
  57.     int operator-=( int );
  58.     WCbool insert( Type& );
  59.  
  60. public:
  61.     inline WCValSListIter() {};
  62.     inline virtual ~WCValSListIter() {};
  63.     inline WCValSListIter( WCValSList<Type> & slist )
  64.          : WCValListIterBase( &slist ) {};
  65. };
  66.  
  67.  
  68.  
  69.  
  70. //
  71. //  This defines an iterator class for the double linked list of
  72. //  values.
  73. //
  74.  
  75. template<class Type>
  76. class WCValDListIter : public WCValListIterBase<Type, WCValDList<Type>,
  77.                                                       WCNIsvDLink<Type> >  {
  78. public:
  79.     inline WCValDListIter() {};
  80.     inline virtual ~WCValDListIter() {};
  81.     inline WCValDListIter( WCValDList<Type> & slist )
  82.          : WCValListIterBase( &slist ) {};
  83. };
  84.  
  85.  
  86.  
  87.  
  88. //
  89. //  This defines an iterator class for the single linked list of
  90. //  pointers.
  91. //
  92. //  The operators --() and -=() and the insert member function are made
  93. //  private to prevent their being used with a single linked list.
  94. //
  95.  
  96. template<class Type>
  97. class WCPtrSListIter : public WCValListIterBase<Type *, WCPtrSList<Type>,
  98.                                                      WCNIsvSLink<Type *> >  {
  99. private:
  100.     int operator--();
  101.     int operator-=( int );
  102.     WCbool insert( Type * );
  103.  
  104. public:
  105.     inline WCPtrSListIter() {};
  106.     inline virtual ~WCPtrSListIter() {};
  107.     inline WCPtrSListIter( WCPtrSList<Type> & slist )
  108.          : WCValListIterBase( &slist ) {};
  109.  
  110.     inline WCbool append( Type * datum ) {
  111.         return( WCValListIterBase::append( datum ) );
  112.     }
  113. };
  114.  
  115.  
  116.  
  117.  
  118. //
  119. //  This defines an iterator class for the double linked list of
  120. //  pointers.
  121. //
  122.  
  123. template<class Type>
  124. class WCPtrDListIter : public WCValListIterBase<Type *, WCPtrDList<Type>,
  125.                                                      WCNIsvDLink<Type *> >  {
  126. public:
  127.     inline WCPtrDListIter() {};
  128.     inline virtual ~WCPtrDListIter() {};
  129.     inline WCPtrDListIter( WCPtrDList<Type> & dlist )
  130.          : WCValListIterBase( &dlist ) {};
  131.  
  132.     inline WCbool insert( Type * datum ) {
  133.         return( WCValListIterBase::insert( datum ) );
  134.     }
  135.  
  136.     inline WCbool append( Type * datum ) {
  137.         return( WCValListIterBase::append( datum ) );
  138.     }
  139. };
  140.  
  141.  
  142.  
  143.  
  144. //
  145. //  This defines an iterator class for the intrusive single linked list.
  146. //
  147. //  The operators --() and -=() and the insert member function are made
  148. //  private to prevent their being used with a single linked list.
  149. //
  150.  
  151. template<class Type>
  152. class WCIsvSListIter : public WCIsvListIterBase<Type, WCIsvSList<Type> > {
  153. private:
  154.     Type * operator--();
  155.     Type * operator-=( int );
  156.     WCbool insert( Type * );
  157.  
  158. public:
  159.     inline WCIsvSListIter() {};
  160.     inline virtual ~WCIsvSListIter() {};
  161.     inline WCIsvSListIter( WCIsvSList<Type> & slist )
  162.          : WCIsvListIterBase( &slist ) {};
  163. };
  164.  
  165.  
  166.  
  167.  
  168. //
  169. //  This defines an iterator class for the intrusive double linked list.
  170. //
  171.  
  172. template<class Type>
  173. class WCIsvDListIter : public WCIsvListIterBase<Type, WCIsvDList<Type> > {
  174. public:
  175.     inline WCIsvDListIter() {};
  176.     inline virtual ~WCIsvDListIter() {};
  177.     inline WCIsvDListIter( WCIsvDList<Type> & dlist )
  178.          : WCIsvListIterBase( &dlist ) {};
  179. };
  180.  
  181.  
  182.  
  183.  
  184. //
  185. //  This defines an iterator class for a constant single linked list of
  186. //  values.  The append member function is made private to prevent it
  187. //  being used with a constant list.
  188. //
  189.  
  190. template<class Type>
  191. class WCValConstSListIter : public WCValSListIter<Type> {
  192. private:
  193.     WCbool append( Type& );
  194.     typedef WCValSList<Type> NonConstList;
  195.  
  196. public:
  197.     inline WCValConstSListIter() {};
  198.     inline virtual ~WCValConstSListIter() {};
  199.     inline WCValConstSListIter( const WCValSList<Type> & slist )
  200.          : WCValSListIter( (NonConstList &)slist ) {};
  201.  
  202.     inline const WCValSList<Type> * container() {
  203.         return( WCValSListIter::container() );
  204.     };
  205.  
  206.     inline void reset() {
  207.         WCValSListIter::reset();
  208.     };
  209.  
  210.     inline void reset( const WCValSList<Type> & slist ) {
  211.         WCValSListIter::reset( (NonConstList &)slist );
  212.     };
  213. };
  214.  
  215.  
  216.  
  217.  
  218. //
  219. //  This defines an iterator class for a constant double linked list of
  220. //  values.  The append and insert member functions are made private to
  221. //  prevent them being used with a constant list.
  222. //
  223.  
  224. template<class Type>
  225. class WCValConstDListIter : public WCValDListIter<Type> {
  226. private:
  227.     WCbool append( Type& );
  228.     WCbool insert( Type& );
  229.     typedef WCValDList<Type> NonConstList;
  230.  
  231. public:
  232.     inline WCValConstDListIter() {};
  233.     inline virtual ~WCValConstDListIter() {};
  234.     inline WCValConstDListIter( const WCValDList<Type> & dlist )
  235.          : WCValDListIter( (NonConstList &)dlist ) {};
  236.  
  237.     inline const WCValDList<Type> * container() {
  238.         return( WCValDListIter::container() );
  239.     };
  240.  
  241.     inline void reset() {
  242.         WCValDListIter::reset();
  243.     };
  244.  
  245.     inline void reset( const WCValDList<Type> & dlist ) {
  246.         WCValDListIter::reset( (NonConstList &)dlist );
  247.     };
  248. };
  249.  
  250.  
  251.  
  252.  
  253. //
  254. //  This defines an iterator class for a constant single linked list of
  255. //  pointers.  The append member function is made private to prevent it
  256. //  being used with a constant list.
  257. //
  258.  
  259. template<class Type>
  260. class WCPtrConstSListIter : public WCPtrSListIter<Type> {
  261. private:
  262.     WCbool append( Type * );
  263.     typedef WCPtrSList<Type> NonConstList;
  264.  
  265. public:
  266.     inline WCPtrConstSListIter() {};
  267.     inline virtual ~WCPtrConstSListIter() {};
  268.     inline WCPtrConstSListIter( const WCPtrSList<Type> & slist )
  269.          : WCPtrSListIter( (NonConstList &)slist ) {};
  270.  
  271.     inline const WCPtrSList<Type> * container() {
  272.         return( WCPtrSListIter::container() );
  273.     };
  274.  
  275.     inline void reset() {
  276.         WCPtrSListIter::reset();
  277.     };
  278.  
  279.     inline void reset( const WCPtrSList<Type> & slist ) {
  280.         WCPtrSListIter::reset( (NonConstList &)slist );
  281.     };
  282. };
  283.  
  284.  
  285.  
  286.  
  287. //
  288. //  This defines an iterator class for a constant double linked list of
  289. //  pointers.  The append and insert member functions are made private to
  290. //  prevent them being used with a constant list.
  291. //
  292.  
  293. template<class Type>
  294. class WCPtrConstDListIter : public WCPtrDListIter<Type> {
  295. private:
  296.     WCbool append( Type * );
  297.     WCbool insert( Type * );
  298.     typedef WCPtrDList<Type> NonConstList;
  299.  
  300. public:
  301.     inline WCPtrConstDListIter() {};
  302.     inline virtual ~WCPtrConstDListIter() {};
  303.     inline WCPtrConstDListIter( const WCPtrDList<Type> & dlist )
  304.          : WCPtrDListIter( (NonConstList &)dlist ) {};
  305.  
  306.     inline const WCPtrDList<Type> * container() {
  307.         return( WCPtrDListIter::container() );
  308.     };
  309.  
  310.     inline void reset() {
  311.         WCPtrDListIter::reset();
  312.     };
  313.  
  314.     inline void reset( const WCPtrDList<Type> & dlist ) {
  315.         WCPtrDListIter::reset( (NonConstList &)dlist );
  316.     };
  317. };
  318.  
  319.  
  320.  
  321.  
  322. //
  323. //  This defines an iterator class for a constant intrusive single linked
  324. //  list.  The append member function is made private to prevent it
  325. //  being used with a constant list.
  326. //
  327.  
  328. template<class Type>
  329. class WCIsvConstSListIter : public WCIsvSListIter<Type> {
  330. private:
  331.     WCbool append( Type * );
  332.     typedef WCIsvSList<Type> NonConstList;
  333.  
  334. public:
  335.     inline WCIsvConstSListIter() {};
  336.     inline virtual ~WCIsvConstSListIter() {};
  337.     inline WCIsvConstSListIter( const WCIsvSList<Type> & slist )
  338.          : WCIsvSListIter( (NonConstList &)slist ) {};
  339.  
  340.     inline const WCIsvSList<Type> * container() {
  341.         return( WCIsvSListIter::container() );
  342.     };
  343.  
  344.     inline void reset() {
  345.         WCIsvSListIter::reset();
  346.     };
  347.  
  348.     inline void reset( const WCIsvSList<Type> & slist ) {
  349.         WCIsvSListIter::reset( (NonConstList &)slist );
  350.     };
  351. };
  352.  
  353.  
  354.  
  355.  
  356. //
  357. //  This defines an iterator class for a constant intrusive double linked
  358. //  pointers.  The append and insert member functions are made private to
  359. //  prevent them being used with a constant list.
  360. //
  361.  
  362. template<class Type>
  363. class WCIsvConstDListIter : public WCIsvDListIter<Type> {
  364. private:
  365.     WCbool append( Type * );
  366.     WCbool insert( Type * );
  367.     typedef WCIsvDList<Type> NonConstList;
  368.  
  369. public:
  370.     inline WCIsvConstDListIter() {};
  371.     inline virtual ~WCIsvConstDListIter() {};
  372.     inline WCIsvConstDListIter( const WCIsvDList<Type> & dlist )
  373.          : WCIsvDListIter( (NonConstList &)dlist ) {};
  374.  
  375.     inline const WCIsvDList<Type> * container() {
  376.         return( WCIsvDListIter::container() );
  377.     };
  378.  
  379.     inline void reset() {
  380.         WCIsvDListIter::reset();
  381.     };
  382.  
  383.     inline void reset( const WCIsvDList<Type> & dlist ) {
  384.         WCIsvDListIter::reset( (NonConstList &)dlist );
  385.     };
  386. };
  387.  
  388. #endif
  389.