#include <cmt_map.h>
Collaboration diagram for cmt_vnode< K, T >:
Public Member Functions | |
cmt_vnode (const K &key, T &t) | |
Required constructor. | |
~cmt_vnode () | |
Destructor. | |
void | clear () |
Recursive clear operation. | |
void | add (const K &key, T &t) |
Add an item. | |
bool | has (const K &key) const |
Finds whether the tree starting from this node contains this key. | |
const T * | find (const K &key) const |
Finds in the tree starting from this node the value associated with this key Return 0 if not found. | |
const cmt_vnode * | find_node (const K &key) const |
Finds in the tree starting from this node the node holding the value associated with this key Return 0 if not found. | |
Protected Attributes | |
cmt_vnode< K, T > * | m_left |
K | m_key |
T | m_t |
cmt_vnode< K, T > * | m_right |
|
Required constructor. Provides the key and the value. Definition at line 185 of file cmt_map.h. Referenced by cmt_vnode< cmt_string, int >::add().
|
|
Destructor.
Definition at line 196 of file cmt_map.h.
00197 { 00198 clear (); 00199 } |
|
Add an item.
Definition at line 221 of file cmt_map.h.
00222 { 00223 if (key < m_key) 00224 { 00225 if (m_left == 0) 00226 { 00227 m_left = new cmt_vnode (key, t); 00228 } 00229 else 00230 { 00231 m_left->add (key, t); 00232 } 00233 } 00234 else if (key > m_key) 00235 { 00236 if (m_right == 0) 00237 { 00238 m_right = new cmt_vnode (key, t); 00239 } 00240 else 00241 { 00242 m_right->add (key, t); 00243 } 00244 } 00245 else 00246 { 00247 m_t = t; 00248 } 00249 } |
|
Recursive clear operation. Will delete sub-nodes Definition at line 205 of file cmt_map.h. Referenced by cmt_vnode< cmt_string, int >::~cmt_vnode().
|
|
Finds in the tree starting from this node the value associated with this key Return 0 if not found.
Definition at line 278 of file cmt_map.h.
|
|
Finds in the tree starting from this node the node holding the value associated with this key Return 0 if not found.
Definition at line 301 of file cmt_map.h.
00302 { 00303 if (key < m_key) 00304 { 00305 if (m_left == 0) return (0); 00306 else return (m_left->find_node (key)); 00307 } 00308 else if (key > m_key) 00309 { 00310 if (m_right == 0) return (0); 00311 else return (m_right->find_node (key)); 00312 } 00313 else 00314 { 00315 return (this); 00316 } 00317 } |
|
Finds whether the tree starting from this node contains this key.
Definition at line 255 of file cmt_map.h.
00256 { 00257 if (key < m_key) 00258 { 00259 if (m_left == 0) return (false); 00260 else return (m_left->has (key)); 00261 } 00262 else if (key > m_key) 00263 { 00264 if (m_right == 0) return (false); 00265 else return (m_right->has (key)); 00266 } 00267 else 00268 { 00269 return (true); 00270 } 00271 } |
|
|
|
|
|
|
|
|