Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBgsetIterator.hxx

Go to the documentation of this file.
00001 #ifndef _CTBgsetIterator_HXX
00002 #define _CTBgsetIterator_HXX 1
00003 
00008 /*----------------------------------------------------------------------------*/
00009 /* C Tool Box: Designed and implemented by:                                   */
00010 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00011 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00012 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00013 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00014 /*------------------------------------------+---------------------------------*/
00015 
00016 template <class K, class V, class C, class T, class AK, class AV>
00017 class CTBgsetBrowser {
00018   public:
00019 
00020     typedef CTBgset<K,V,C,T,AK,AV>          Gset;
00021     typedef CTBgsetNode<K,V,C,T,AK,AV>      Node;
00022     typedef CTBgsetBrowser<K,V,C,T,AK,AV>   Browser;
00023 
00024                     CTBgsetBrowser();
00025                     CTBgsetBrowser(const CTBgset<K,V,C,T,AK,AV>* p_gset,
00026                                    const CTBgsetNode<K,V,C,T,AK,AV>* p_node);
00027 
00028     bool            Next();
00029     bool            Prev();
00030 
00031     bool            Valid() const;
00032     bool            IsFirst() const;
00033     bool            IsLast() const;
00034     CTBint          Rank() const;
00035 
00036     bool            Equal(const CTBgsetBrowser<K,V,C,T,AK,AV>& rhs) const;
00037 
00038     const K&        Key() const;
00039     const V&        Value() const;
00040     const T&        Object() const;
00041 
00042     CTBgsetBrowser<K,V,C,T,AK,AV>& operator++();
00043     CTBgsetBrowser<K,V,C,T,AK,AV>  operator++(int);
00044 
00045     CTBgsetBrowser<K,V,C,T,AK,AV>& operator--();
00046     CTBgsetBrowser<K,V,C,T,AK,AV>  operator--(int);
00047 
00048     const T&        operator[](CTBint i_offset);
00049 
00050     const T*        operator->();
00051     const T&        operator*();
00052 
00053     CTBgsetBrowser<K,V,C,T,AK,AV>& operator+=(CTBint i_offset);
00054     CTBgsetBrowser<K,V,C,T,AK,AV>& operator-=(CTBint i_offset);
00055 
00056                     operator const T*() const;
00057                     operator bool() const;
00058 
00059                     operator const CTBgsetNode<K,V,C,T,AK,AV>*() const;
00060 
00061   protected:
00062 
00063     Gset*           mp_gset;                
00064     Node*           mp_node;                
00065 };
00066 
00067 template <class K, class V, class C, class T, class AK, class AV>
00068 CTBgsetBrowser<K,V,C,T,AK,AV> operator+(
00069                                 const CTBgsetBrowser<K,V,C,T,AK,AV>& lhs,
00070                                 CTBint i_offset);
00071 template <class K, class V, class C, class T, class AK, class AV>
00072 CTBgsetBrowser<K,V,C,T,AK,AV> operator-(
00073                                 const CTBgsetBrowser<K,V,C,T,AK,AV>& lhs,
00074                                 CTBint i_offset);
00075 
00076 template <class K, class V, class C, class T, class AK, class AV>
00077 CTBint operator-(const CTBgsetBrowser<K,V,C,T,AK,AV>& lhs,
00078                  const CTBgsetBrowser<K,V,C,T,AK,AV>& rhs);
00079 
00080 template <class K, class V, class C, class T, class AK, class AV>
00081 bool operator==(const CTBgsetBrowser<K,V,C,T,AK,AV>& lhs,
00082                 const CTBgsetBrowser<K,V,C,T,AK,AV>& rhs);
00083 
00084 template <class K, class V, class C, class T, class AK, class AV>
00085 ostream& operator<<(ostream& os, const CTBgsetBrowser<K,V,C,T,AK,AV>& obj);
00086 
00087 //##############################################################################
00088 
00089 template <class K, class V, class C, class T, class AK, class AV>
00090 class CTBgsetIterator : public CTBgsetBrowser<K,V,C,T,AK,AV> {
00091   public:
00092 
00093     typedef CTBgsetIterator<K,V,C,T,AK,AV>  Iterator;
00094 
00095                     CTBgsetIterator();
00096                     CTBgsetIterator(CTBgset<K,V,C,T,AK,AV>* p_gset,
00097                                     CTBgsetNode<K,V,C,T,AK,AV>* p_node);
00098 
00099     V&              Value() const;
00100     T&              Object() const;
00101 
00102     CTBgsetIterator<K,V,C,T,AK,AV>& operator++();
00103     CTBgsetIterator<K,V,C,T,AK,AV>  operator++(int);
00104 
00105     CTBgsetIterator<K,V,C,T,AK,AV>& operator--();
00106     CTBgsetIterator<K,V,C,T,AK,AV>  operator--(int);
00107   
00108     T&              operator[](CTBint i_offset);
00109 
00110     T*              operator->();
00111     T&              operator*();
00112 
00113     CTBgsetIterator<K,V,C,T,AK,AV>& operator+=(CTBint i_offset);
00114     CTBgsetIterator<K,V,C,T,AK,AV>& operator-=(CTBint i_offset);
00115 
00116                     operator T*() const;
00117                     operator bool() const;
00118 
00119                     operator CTBgsetNode<K,V,C,T,AK,AV>*() const;
00120 };
00121 
00122 template <class K, class V, class C, class T, class AK, class AV>
00123 CTBgsetIterator<K,V,C,T,AK,AV> operator+(
00124                                  const CTBgsetIterator<K,V,C,T,AK,AV>& lhs,
00125                                  CTBint i_offset);
00126 template <class K, class V, class C, class T, class AK, class AV>
00127 CTBgsetIterator<K,V,C,T,AK,AV> operator-(
00128                                  const CTBgsetIterator<K,V,C,T,AK,AV>& lhs,
00129                                  CTBint i_offset);
00130 
00131 // Notes:
00132 //  1. CTBgsetIterator and CTBgsetBrowser implement the read/write and read-only
00133 //     interface and have thus many almost identical methods.
00134 //      ==> do all changes in these two classes in a consistent fashion !!!
00135 //
00136 //  2. It is necessary to have a bool conversion on Iterator. Otherwise
00137 //     egcs complains about ambiguities between the pointer conversions and
00138 //     the base class bool conversion. 
00139 
00140 #include "CTBgsetIterator.icc"
00141 
00142 #endif

Generated at Fri Oct 24 18:11:28 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001