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

CTBmapIterator.hxx

Go to the documentation of this file.
00001 #ifndef _CTBmapIterator_HXX
00002 #define _CTBmapIterator_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>
00017 class CTBmapBrowser {
00018   public:
00019 
00020     typedef CTBmap<K,V,C>          Map;
00021     typedef CTBmapNode<K,V,C>      Node;
00022     typedef CTBmapBrowser<K,V,C>   Browser;
00023 
00024                     CTBmapBrowser();
00025                     CTBmapBrowser(const CTBmap<K,V,C>* p_map,
00026                                   const CTBmapNode<K,V,C>* 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 CTBmapBrowser<K,V,C>& rhs) const;
00037 
00038     const CTBpair<const K,V>* Current() const;
00039 
00040     const K&        Key() const;
00041     const V&        Value() const;
00042 
00043     CTBmapBrowser<K,V,C>& operator++();
00044     CTBmapBrowser<K,V,C>  operator++(int);
00045 
00046     CTBmapBrowser<K,V,C>& operator--();
00047     CTBmapBrowser<K,V,C>  operator--(int);
00048 
00049     const CTBpair<const K,V>& operator[](CTBint i_offset);
00050 
00051     const CTBpair<const K,V>* operator->();
00052     const CTBpair<const K,V>& operator*();
00053 
00054     CTBmapBrowser<K,V,C>& operator+=(CTBint i_offset);
00055     CTBmapBrowser<K,V,C>& operator-=(CTBint i_offset);
00056 
00057                     operator const CTBpair<const K,V>*() const;
00058                     operator bool() const;
00059 
00060                     operator const CTBmapNode<K,V,C>*() const;
00061 
00062   protected:
00063 
00064     Map*            mp_map;                 
00065     Node*           mp_node;                
00066 };
00067 
00068 template <class K, class V, class C>
00069 CTBmapBrowser<K,V,C> operator+(const CTBmapBrowser<K,V,C>& lhs,
00070                                CTBint i_offset);
00071 template <class K, class V, class C>
00072 CTBmapBrowser<K,V,C> operator-(const CTBmapBrowser<K,V,C>& lhs,
00073                                CTBint i_offset);
00074 
00075 template <class K, class V, class C>
00076 CTBint operator-(const CTBmapBrowser<K,V,C>& lhs,
00077                  const CTBmapBrowser<K,V,C>& rhs);
00078 
00079 template <class K, class V, class C>
00080 bool operator==(const CTBmapBrowser<K,V,C>& lhs,
00081                 const CTBmapBrowser<K,V,C>& rhs);
00082 
00083 template <class K, class V, class C>
00084 ostream& operator<<(ostream& os, const CTBmapBrowser<K,V,C>& obj);
00085 
00086 //##############################################################################
00087 
00088 template <class K, class V, class C>
00089 class CTBmapIterator : public CTBmapBrowser<K,V,C> {
00090   public:
00091 
00092     typedef CTBmapIterator<K,V,C>  Iterator;
00093 
00094                     CTBmapIterator();
00095                     CTBmapIterator(CTBmap<K,V,C>* p_map,
00096                                    CTBmapNode<K,V,C>* p_node);
00097 
00098     CTBpair<const K,V>* Current() const;
00099 
00100     V&              Value() const;
00101 
00102     CTBmapIterator<K,V,C>& operator++();
00103     CTBmapIterator<K,V,C>  operator++(int);
00104 
00105     CTBmapIterator<K,V,C>& operator--();
00106     CTBmapIterator<K,V,C>  operator--(int);
00107   
00108     CTBpair<const K,V>& operator[](CTBint i_offset);
00109 
00110     CTBpair<const K,V>* operator->();
00111     CTBpair<const K,V>& operator*();
00112 
00113     CTBmapIterator<K,V,C>& operator+=(CTBint i_offset);
00114     CTBmapIterator<K,V,C>& operator-=(CTBint i_offset);
00115 
00116                     operator CTBpair<const K,V>*() const;
00117                     operator bool() const;
00118 
00119                     operator CTBmapNode<K,V,C>*() const;
00120 };
00121 
00122 template <class K, class V, class C>
00123 CTBmapIterator<K,V,C> operator+(const CTBmapIterator<K,V,C>& lhs,
00124                                 CTBint i_offset);
00125 template <class K, class V, class C>
00126 CTBmapIterator<K,V,C> operator-(const CTBmapIterator<K,V,C>& lhs,
00127                                 CTBint i_offset);
00128 
00129 // Notes:
00130 //  1. CTBmapIterator and CTBmapBrowser implement the read/write and read-only
00131 //     interface and have thus many almost identical methods.
00132 //      ==> do all changes in these two classes in a consistent fashion !!!
00133 //
00134 //  2. It is necessary to have a bool conversion on Iterator. Otherwise
00135 //     egcs complains about ambiguities between the pointer conversions and
00136 //     the base class bool conversion. 
00137 //
00138 // the implementation is fully inlined and always included here
00139 //
00140 #include "CTBmapIterator.icc"
00141 
00142 #endif

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