00001 #ifndef _CTBmap_HXX
00002 #define _CTBmap_HXX 1
00003
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "CTBpair.hxx"
00017 #include "CTBbtree.hxx"
00018
00019 template <class K, class V, class C>
00020 class CTBmapNode;
00021 template <class K, class V, class C>
00022 class CTBmapIterator;
00023 template <class K, class V, class C>
00024 class CTBmapBrowser;
00025
00026 template <class K, class V, class C>
00027 class CTBmap : private CTBbtree {
00028 public:
00029
00030 typedef CTBmap<K,V,C> Map;
00031 typedef CTBmapNode<K,V,C> Node;
00032 typedef CTBmapIterator<K,V,C> Iterator;
00033 typedef CTBmapBrowser<K,V,C> Browser;
00034
00035 CTBmap();
00036 CTBmap(const CTBmap<K,V,C>& rhs);
00037
00038 ~CTBmap();
00039
00040 bool Insert(const CTBpair<const K,V>& pair);
00041 bool Insert(const K& key, const V& value);
00042 bool Insert(const K& key);
00043
00044 CTBmapIterator<K,V,C> Find(const K& key);
00045 CTBmapBrowser<K,V,C> Find(const K& key) const;
00046
00047 CTBmapIterator<K,V,C> FindLessEqual(const K& key, bool& b_found);
00048 CTBmapBrowser<K,V,C> FindLessEqual(const K& key, bool& b_found) const;
00049
00050 CTBmapIterator<K,V,C> FindGreaterEqual(const K& key, bool& b_found);
00051 CTBmapBrowser<K,V,C> FindGreaterEqual(const K& key, bool& b_found) const;
00052
00053 CTBmapIterator<K,V,C> FindOrCreate(const K& key, bool& b_found);
00054
00055 bool Rename(const K& keyold, const K& keynew);
00056 bool Rename(const CTBmapIterator<K,V,C>& p, const K& keynew);
00057
00058 bool Delete(const K& key);
00059 bool Delete(const CTBmapIterator<K,V,C>& p);
00060 void Clear();
00061
00062 CTBmapIterator<K,V,C> First();
00063 CTBmapBrowser<K,V,C> First() const;
00064
00065 CTBmapIterator<K,V,C> Last();
00066 CTBmapBrowser<K,V,C> Last() const;
00067
00068 CTBint Size() const;
00069
00070 void Dump(int i_indent=0, ostream& os=cout,
00071 const char* p_text=0) const;
00072
00073 V& operator[](const K& key);
00074
00075 CTBmap<K,V,C>& operator=(const CTBmap<K,V,C>& rhs);
00076
00077 operator bool() const;
00078
00079 private:
00080
00081 CTBmapNode<K,V,C>* LocateMatchOrBound(const K& key, int& i_mtype) const;
00082
00083 CTBmapNode<K,V,C>* LocateMatchOrPrev(const K& key, bool& b_found) const;
00084 CTBmapNode<K,V,C>* LocateMatchOrNext(const K& key, bool& b_found) const;
00085
00086 void InsertNode(CTBmapNode<K,V,C>* p_node,
00087 CTBmapNode<K,V,C>* p_parent, int i_ctype);
00088
00089 void RemoveNode(CTBmapNode<K,V,C>* p_node);
00090 };
00091
00092 #include "CTBmapNode.hxx"
00093 #include "CTBmapIterator.hxx"
00094
00095 #include "CTBmap.icc"
00096
00097 #endif