62 template <
typename Key,
typename Data >
71 template <
typename Key,
typename Data >
79 template <
typename Key,
typename Data >
88 template <
typename Key,
typename Data >
116 template <
typename Key,
typename Data >
152 template <
typename Key,
typename Data >
162 template <
typename Key,
typename Data >
173 for (i = 0; i + 1 < index.size(); ++i) {
178 current_node->
children.insert(index[i], new_node);
180 current_node = new_node;
181 }
else current_node = current_node->
children[index[i]];
189 if (i + 1 == index.size()) {
191 if (current_node->
children.exists(index[i])) {
199 current_node->
children.insert(index[i], new_node);
201 new_node->
parent = current_node;
211 template <
typename Key,
typename Data >
222 for (i = 0; i + 1 < index.size(); ++i) {
227 current_node->
children.insert(index[i], new_node);
229 current_node = new_node;
230 }
else current_node = current_node->
children[index[i]];
238 if (i + 1 == index.size()) {
240 if (current_node->
children.exists(index[i])) {
247 current_node->
children.insert(index[i], new_node);
249 new_node->
parent = current_node;
259 template <
typename Key,
typename Data >
270 for (i = 0; i + 1 < index.size(); ++i) {
275 current_node->
children.insert(index[i], new_node);
277 current_node = new_node;
278 }
else current_node = current_node->
children[index[i]];
286 if (i + 1 == index.size()) {
288 if (current_node->
children.exists(index[i])) {
293 node->
data = theData;
297 current_node->
children.insert(index[i], new_node);
298 new_node->
parent = current_node;
311 template <
typename Key,
typename Data >
322 for (i = 0; i + 1 < index.size(); ++i) {
327 current_node->
children.insert(index[i], new_node);
329 current_node = new_node;
330 }
else current_node = current_node->
children[index[i]];
338 if (i + 1 == index.size()) {
340 if (current_node->
children.exists(index[i])) {
345 node->
data =
new Data(theData);
349 current_node->
children.insert(index[i], new_node);
350 new_node->
parent = current_node;
357 data =
new Data(theData);
363 template <
typename Key,
typename Data >
367 for (
unsigned int i = 0; i < index.size(); ++i)
368 current_node = current_node->
children[index[i]];
372 return *(current_node->
data);
377 template <
typename Key,
typename Data >
382 for (
unsigned int i = 0; i < index.size(); ++i)
383 current_node = current_node->
children[index[i]];
385 return *current_node;
Safe Iterators for hashtables.
Exception : a similar element already exists.
The class for storing the nodes of the Arborescence.
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.
~IndexedTree()
Class destructor.
void setNode(const std::vector< Key > &index, Data *data)
Updates the value of a node (or adds it if it does not already exist).
Data & getData(const std::vector< Key > &index) const
Returns the value of a given node of the tree.
HashTable< Key, IndexedTree< Key, Data > * > children
The list of children nodes of the current node.
Key key
The key of the current node.
IndexedTree< Key, Data > * parent
The parent of the node.
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.
IndexedTree(Data *data=nullptr)
Creates a tree with one node with or without data.
Exception : the element we looked for cannot be found.
#define GUM_ERROR(type, msg)
Class for storing trees (as data structures, not graphs).
gum is the global namespace for all aGrUM entities