00001 #ifndef _CTBmapIterator_HXX
00002 #define _CTBmapIterator_HXX 1
00003
00008
00009
00010
00011
00012
00013
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
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 #include "CTBmapIterator.icc"
00141
00142 #endif