63 template <
typename Key,
typename Data >
72 template <
typename Key,
typename Data >
80 template <
typename Key,
typename Data >
89 template <
typename Key,
typename Data >
117 template <
typename Key,
typename Data >
153 template <
typename Key,
typename Data >
163 template <
typename Key,
typename Data >
174 for (i = 0; i + 1 < index.size(); ++i) {
179 current_node->
children.insert(index[i], new_node);
181 current_node = new_node;
182 }
else current_node = current_node->
children[index[i]];
190 if (i + 1 == index.size()) {
192 if (current_node->
children.exists(index[i])) {
200 current_node->
children.insert(index[i], new_node);
202 new_node->
parent = current_node;
212 template <
typename Key,
typename Data >
223 for (i = 0; i + 1 < index.size(); ++i) {
228 current_node->
children.insert(index[i], new_node);
230 current_node = new_node;
231 }
else current_node = current_node->
children[index[i]];
239 if (i + 1 == index.size()) {
241 if (current_node->
children.exists(index[i])) {
248 current_node->
children.insert(index[i], new_node);
250 new_node->
parent = current_node;
260 template <
typename Key,
typename Data >
271 for (i = 0; i + 1 < index.size(); ++i) {
276 current_node->
children.insert(index[i], new_node);
278 current_node = new_node;
279 }
else current_node = current_node->
children[index[i]];
287 if (i + 1 == index.size()) {
289 if (current_node->
children.exists(index[i])) {
294 node->
data = theData;
298 current_node->
children.insert(index[i], new_node);
299 new_node->
parent = current_node;
312 template <
typename Key,
typename Data >
323 for (i = 0; i + 1 < index.size(); ++i) {
328 current_node->
children.insert(index[i], new_node);
330 current_node = new_node;
331 }
else current_node = current_node->
children[index[i]];
339 if (i + 1 == index.size()) {
341 if (current_node->
children.exists(index[i])) {
346 node->
data =
new Data(theData);
350 current_node->
children.insert(index[i], new_node);
351 new_node->
parent = current_node;
358 data =
new Data(theData);
364 template <
typename Key,
typename Data >
368 for (
unsigned int i = 0; i < index.size(); ++i)
369 current_node = current_node->
children[index[i]];
373 return *(current_node->
data);
378 template <
typename Key,
typename Data >
383 for (
unsigned int i = 0; i < index.size(); ++i)
384 current_node = current_node->
children[index[i]];
386 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.
IndexedTree< Key, Data > & getNode(const std::vector< Key > &index) const
Returns a given node of the tree.
void setNode(const std::vector< Key > &index, Data *data)
Updates the value of a node (or adds it if it does not already exist).
HashTable< Key, IndexedTree< Key, Data > * > children
The list of children nodes of the current node.
Key key
The key of the current node.
Data & getData(const std::vector< Key > &index) const
Returns the value of a given node of the tree.
IndexedTree< Key, Data > * parent
The parent of the node.
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