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