39 template <
typename Key,
typename Data >
41 key(theKey), data(theData), parent(0) {
48 template <
typename Key,
typename Data >
56 template <
typename Key,
typename Data >
65 template <
typename Key,
typename Data >
94 template <
typename Key,
typename Data >
133 template <
typename Key,
typename Data >
143 template <
typename Key,
typename Data >
145 const Data* theData) {
155 for (i = 0; i + 1 < index.size(); ++i) {
161 current_node->
children.insert(index[i], new_node);
163 current_node = new_node;
165 current_node = current_node->
children[index[i]];
173 if (i + 1 == index.size()) {
175 if (current_node->
children.exists(index[i])) {
183 current_node->
children.insert(index[i], new_node);
185 new_node->
parent = current_node;
195 template <
typename Key,
typename Data >
197 const Data& theData) {
207 for (i = 0; i + 1 < index.size(); ++i) {
213 current_node->
children.insert(index[i], new_node);
215 current_node = new_node;
217 current_node = current_node->
children[index[i]];
225 if (i + 1 == index.size()) {
227 if (current_node->
children.exists(index[i])) {
235 current_node->
children.insert(index[i], new_node);
237 new_node->
parent = current_node;
247 template <
typename Key,
typename Data >
259 for (i = 0; i + 1 < index.size(); ++i) {
265 current_node->
children.insert(index[i], new_node);
267 current_node = new_node;
269 current_node = current_node->
children[index[i]];
277 if (i + 1 == index.size()) {
279 if (current_node->
children.exists(index[i])) {
284 node->
data = theData;
289 current_node->
children.insert(index[i], new_node);
290 new_node->
parent = current_node;
303 template <
typename Key,
typename Data >
305 const Data& theData) {
315 for (i = 0; i + 1 < index.size(); ++i) {
321 current_node->
children.insert(index[i], new_node);
323 current_node = new_node;
325 current_node = current_node->
children[index[i]];
333 if (i + 1 == index.size()) {
335 if (current_node->
children.exists(index[i])) {
340 node->
data =
new Data(theData);
345 current_node->
children.insert(index[i], new_node);
346 new_node->
parent = current_node;
353 data =
new Data(theData);
359 template <
typename Key,
typename Data >
365 for (
unsigned int i = 0; i < index.size(); ++i)
366 current_node = current_node->
children[index[i]];
370 return *(current_node->
data);
375 template <
typename Key,
typename Data >
381 for (
unsigned int i = 0; i < index.size(); ++i)
382 current_node = current_node->
children[index[i]];
384 return *current_node;
Data & getData(const std::vector< Key > &index) const
Returns the value of a given node of the tree.
The class for storing the nodes of the Arborescence.
IndexedTree< Key, Data > * parent
The parent of the node.
IndexedTree(Data *data=nullptr)
Creates a tree with one node with or without data.
HashTable< Key, IndexedTree< Key, Data > *> children
The list of children nodes of the current node.
void insertNode(const std::vector< Key > &index, const Data *data)
Adds a new node into the tree.
Data * data
The data stored into the node.
Safe Iterators for hashtables.
gum is the global namespace for all aGrUM entities
IndexedTree< Key, Data > & getNode(const std::vector< Key > &index) const
Returns a given node of the tree.
IndexedTree< Key, Data > & operator=(const IndexedTree< Key, Data > &from)
Copy operator.
void setNode(const std::vector< Key > &index, Data *data)
Updates the value of a node (or adds it if it does not already exist).
Key key
The key of the current node.
Class for storing trees (as data structures, not graphs).
~IndexedTree()
Class destructor.
#define GUM_ERROR(type, msg)