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

  1. //
  2. //  wcskipit.h  Definitions for the WATCOM Container Skip List Iterator
  3. //              Classes
  4. //
  5. //  Copyright by WATCOM International Corp. 1988-1996.  All rights reserved.
  6. //
  7. #ifndef _WCSKIPIT_H_INCLUDED
  8. #define _WCSKIPIT_H_INCLUDED
  9.  
  10. #ifndef __cplusplus
  11. #error wcskipit.h is for use with C++
  12. #endif
  13.  
  14. #ifndef _WCDEFS_H_INCLUDED
  15.  #include <wcdefs.h>
  16. #endif
  17. #ifndef _WCEXCEPT_H_INCLUDED
  18.  #include <wcexcept.h>
  19. #endif
  20. #ifndef _WCSKIP_H_INCLUDED
  21.  #include <wcskip.h>
  22. #endif
  23. #ifndef _WCSIBASE_H_INCLUDED
  24.  #include <wcsibase.h>
  25. #endif
  26.  
  27.  
  28.  
  29.  
  30. //
  31. // The WCValSkipListIter is the iterator for the WCValSkipList class
  32. //
  33.  
  34. template<class Type>
  35. class WCValSkipListIter : public WCSkipListIterBase<Type> {
  36. public:
  37.     inline WCValSkipListIter() {};
  38.  
  39.     inline WCValSkipListIter( const WCValSkipList<Type>& skip_list )
  40.                 : WCSkipListIterBase( skip_list ) {};
  41.  
  42.     inline ~WCValSkipListIter() {};
  43.  
  44.     inline const WCValSkipList<Type> *container() const {
  45.         return (const WCValSkipList<Type> *)WCSkipListIterBase::container();
  46.     };
  47.  
  48.     inline void reset() {
  49.         WCSkipListIterBase::reset();
  50.     };
  51.  
  52.     inline void reset( const WCValSkipList<Type> &skip_list ) {
  53.         WCSkipListIterBase::reset( skip_list );
  54.     };
  55. };
  56.  
  57.  
  58.  
  59. //
  60. // The WCPtrSkipListIter is the iterator for the WCPtrSkipList class.
  61. //
  62.  
  63. template<class Type>
  64. class WCPtrSkipListIter : public WCSkipListIterBase<void *> {
  65. public:
  66.     inline WCPtrSkipListIter() {};
  67.  
  68.     inline WCPtrSkipListIter( const WCPtrSkipList<Type>& skip_list )
  69.                 : WCSkipListIterBase( skip_list ) {};
  70.  
  71.     inline ~WCPtrSkipListIter() {};
  72.  
  73.     inline const WCPtrSkipList<Type> *container() const {
  74.         return( (const WCPtrSkipList<Type> *)WCSkipListIterBase::container() );
  75.     };
  76.  
  77.     inline Type *current() const {
  78.         return( (Type *)WCSkipListIterBase::current() );
  79.     };
  80.  
  81.     inline void reset() {
  82.         WCSkipListIterBase::reset();
  83.     };
  84.  
  85.     inline void reset( const WCPtrSkipList<Type> &skip_list ) {
  86.         WCSkipListIterBase::reset( skip_list );
  87.     };
  88. };
  89.  
  90.  
  91.  
  92.  
  93. //
  94. // The WCValSkipListSetIter is the iterator for the WCValSkipListSet class
  95. //
  96.  
  97. template<class Type>
  98. class WCValSkipListSetIter : public WCSkipListIterBase<Type> {
  99. public:
  100.     inline WCValSkipListSetIter() {};
  101.  
  102.     inline WCValSkipListSetIter( const WCValSkipListSet<Type>& skip_list )
  103.                 : WCSkipListIterBase( skip_list ) {};
  104.  
  105.     inline ~WCValSkipListSetIter() {};
  106.  
  107.     inline const WCValSkipListSet<Type> *container() const {
  108.         return (const WCValSkipListSet<Type> *)WCSkipListIterBase::container();
  109.     };
  110.  
  111.     inline void reset() {
  112.         WCSkipListIterBase::reset();
  113.     };
  114.  
  115.     inline void reset( const WCValSkipListSet<Type> &skip_list ) {
  116.         WCSkipListIterBase::reset( skip_list );
  117.     };
  118. };
  119.  
  120.  
  121.  
  122. //
  123. // The WCPtrSkipListSetIter is the iterator for the WCPtrSkipListSet class.
  124. //
  125.  
  126. template<class Type>
  127. class WCPtrSkipListSetIter : public WCSkipListIterBase<void *> {
  128. public:
  129.     inline WCPtrSkipListSetIter() {};
  130.  
  131.     inline WCPtrSkipListSetIter( const WCPtrSkipListSet<Type>& skip_list )
  132.                 : WCSkipListIterBase( skip_list ) {};
  133.  
  134.     inline ~WCPtrSkipListSetIter() {};
  135.  
  136.     inline const WCPtrSkipListSet<Type> *container() const {
  137.         return( (const WCPtrSkipListSet<Type> *)WCSkipListIterBase
  138.                                                         ::container() );
  139.     };
  140.  
  141.     inline Type *current() const {
  142.         return( (Type *)WCSkipListIterBase::current() );
  143.     };
  144.  
  145.     inline void reset() {
  146.         WCSkipListIterBase::reset();
  147.     };
  148.  
  149.     inline void reset( const WCPtrSkipListSet<Type> &skip_list ) {
  150.         WCSkipListIterBase::reset( skip_list );
  151.     };
  152. };
  153.  
  154.  
  155.  
  156.  
  157. //
  158. // The WCValSkipListDictIter is the iterator for the WCValSkipListDict class.
  159. //
  160. // private inheritance is used to hide the current member function.
  161. //
  162.  
  163. template<class Key, class Value>
  164. class WCValSkipListDictIter
  165.         : private WCSkipListIterBase<WCSkipListDictKeyVal<Key, Value> > {
  166. public:
  167.     inline WCValSkipListDictIter() {};
  168.  
  169.     inline WCValSkipListDictIter( const WCValSkipListDict<Key, Value>& hash )
  170.                 : WCSkipListIterBase( hash ) {};
  171.  
  172.     inline ~WCValSkipListDictIter() {};
  173.  
  174.     inline const WCValSkipListDict<Key, Value> *container() const {
  175.         return( (const WCValSkipListDict<Key, Value> *)WCSkipListIterBase
  176.                         ::container() );
  177.     };
  178.  
  179.     inline wciter_state exceptions() const {
  180.         return( WCSkipListIterBase::exceptions() );
  181.     };
  182.  
  183.     inline wciter_state exceptions( wciter_state const set_flags ) {
  184.         return( WCSkipListIterBase::exceptions( set_flags ) );
  185.     };
  186.  
  187.     Key key() const;
  188.  
  189.     inline void reset() {
  190.         WCSkipListIterBase::reset();
  191.     };
  192.  
  193.     inline void reset( const WCValSkipListDict<Key, Value> &hash ) {
  194.         WCSkipListIterBase::reset( hash );
  195.     };
  196.  
  197.     Value value() const;
  198.  
  199.     inline WCbool operator++() {
  200.         return( WCSkipListIterBase::operator++() );
  201.     };
  202.  
  203.     inline WCbool operator()() {
  204.         return( WCSkipListIterBase::operator()() );
  205.     };
  206. };
  207.  
  208.  
  209. template <class Key, class Value>
  210. Key WCValSkipListDictIter<Key, Value>::key() const {
  211.     if( curr == 0 ) {
  212.         base_throw_undef_item();
  213.         Key temp;
  214.         return( temp );
  215.     }
  216.     return( base_curr_node()->data.key );
  217. };
  218.  
  219.  
  220. template <class Key, class Value>
  221. Value WCValSkipListDictIter<Key, Value>::value() const {
  222.     if( curr == 0 ) {
  223.         base_throw_undef_item();
  224.         Value temp;
  225.         return( temp );
  226.     }
  227.     return( base_curr_node()->data.value );
  228. };
  229.  
  230.  
  231.  
  232.  
  233. //
  234. // The WCPtrSkipListDictIter is the iterator for the WCPtrSkipListDict class.
  235. //
  236.  
  237. template<class Key, class Value>
  238. class WCPtrSkipListDictIter
  239.         : public WCValSkipListDictIter<void *, void *> {
  240. public:
  241.     inline WCPtrSkipListDictIter() {};
  242.  
  243.     inline WCPtrSkipListDictIter( const WCPtrSkipListDict<Key, Value>& hash )
  244.                 : WCValSkipListDictIter( hash ) {};
  245.  
  246.     inline ~WCPtrSkipListDictIter() {};
  247.  
  248.     inline const WCPtrSkipListDict<Key, Value> *container() const {
  249.         return( (const WCPtrSkipListDict<Key, Value> *)WCValSkipListDictIter
  250.                                                         ::container() );
  251.     };
  252.  
  253.     inline Key * key() const {
  254.         return( (Key *)WCValSkipListDictIter::key() );
  255.     };
  256.  
  257.     inline void reset() {
  258.         WCValSkipListDictIter::reset();
  259.     };
  260.  
  261.     inline void reset( const WCPtrSkipListDict<Key, Value> &hash ) {
  262.         WCValSkipListDictIter::reset( hash );
  263.     };
  264.  
  265.     Value *value() const {
  266.         return( (Value *)WCValSkipListDictIter::value() );
  267.     };
  268. };
  269.  
  270. #endif
  271.