#include <cmt_map.h>
Inheritance diagram for cmt_node< K, T >:
Public Methods |
|
| ? | cmt_node (const K &key, T &t) |
| ? |
Required constructor. |
| ? | ~cmt_node () |
| ? |
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. |
| 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_node *? | 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_node< K, T > *? | m_left |
| K? | m_key |
| T *? | m_t |
| cmt_node< K, T > *? | m_right |
Implements a binary tree of T* keyed by the class K
The class K must have the < and > operators.
This is the basic constituent for the cmt_map class.
Definition at line 19 of file cmt_map.h.
|
||||||||||||||||
| ? |
Required constructor. Provides the key and the value. Definition at line 27 of file cmt_map.h. Referenced by cmt_node< cmt_string, Package >::add(). |
|
|||||||||
| ? |
Destructor. Definition at line 38 of file cmt_map.h. 00039 {
00040 clear ();
00041 }
|
|
||||||||||||||||
| ? |
Add an item. Definition at line 65 of file cmt_map.h. 00066 {
00067 if (key < m_key)
00068 {
00069 if (m_left == 0)
00070 {
00071 m_left = new cmt_node (key, t);
00072 }
00073 else
00074 {
00075 m_left->add (key, t);
00076 }
00077 }
00078 else if (key > m_key)
00079 {
00080 if (m_right == 0)
00081 {
00082 m_right = new cmt_node (key, t);
00083 }
00084 else
00085 {
00086 m_right->add (key, t);
00087 }
00088 }
00089 else
00090 {
00091 m_t = &t;
00092 }
00093 }
|
|
|||||||||
| ? |
Recursive clear operation. Will delete sub-nodes Definition at line 47 of file cmt_map.h. Referenced by cmt_node< cmt_string, Package >::~cmt_node(). |
|
||||||||||
| ? |
Finds in the tree starting from this node the value associated with this key Return 0 if not found. |
|
||||||||||
| ? |
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 145 of file cmt_map.h. 00146 {
00147 if (key < m_key)
00148 {
00149 if (m_left == 0) return (0);
00150 else return (m_left->find_node (key));
00151 }
00152 else if (key > m_key)
00153 {
00154 if (m_right == 0) return (0);
00155 else return (m_right->find_node (key));
00156 }
00157 else
00158 {
00159 return (this);
00160 }
00161 }
|
|
||||||||||
| ? |
Finds whether the tree starting from this node contains this key. Definition at line 99 of file cmt_map.h. 00100 {
00101 if (key < m_key)
00102 {
00103 if (m_left == 0) return (false);
00104 else return (m_left->has (key));
00105 }
00106 else if (key > m_key)
00107 {
00108 if (m_right == 0) return (false);
00109 else return (m_right->has (key));
00110 }
00111 else
00112 {
00113 return (true);
00114 }
00115 }
|
|
|||||
| ? |
Definition at line 165 of file cmt_map.h. Referenced by cmt_node< cmt_string, Package >::add(), cmt_node< cmt_string, Package >::cmt_node(), cmt_node< cmt_string, Package >::find(), cmt_node< cmt_string, Package >::find_node(), and cmt_node< cmt_string, Package >::has(). |
|
|||||
|
|||||
|
|||||
| ? |
Definition at line 166 of file cmt_map.h. Referenced by cmt_node< cmt_string, Package >::add(), cmt_node< cmt_string, Package >::clear(), and cmt_node< cmt_string, Package >::cmt_node(). |