42 template <
typename Key,
typename Data >
44 key(theKey), data(theData), parent(0) {
51 template <
typename Key,
typename Data >
59 template <
typename Key,
typename Data >
68 template <
typename Key,
typename Data >
97 template <
typename Key,
typename Data >
136 template <
typename Key,
typename Data >
146 template <
typename Key,
typename Data >
148 const Data* theData) {
158 for (i = 0; i + 1 < index.size(); ++i) {
164 current_node->
children.insert(index[i], new_node);
166 current_node = new_node;
168 current_node = current_node->
children[index[i]];
176 if (i + 1 == index.size()) {
178 if (current_node->
children.exists(index[i])) {
186 current_node->
children.insert(index[i], new_node);
188 new_node->
parent = current_node;
198 template <
typename Key,
typename Data >
200 const Data& theData) {
210 for (i = 0; i + 1 < index.size(); ++i) {
216 current_node->
children.insert(index[i], new_node);
218 current_node = new_node;
220 current_node = current_node->
children[index[i]];
228 if (i + 1 == index.size()) {
230 if (current_node->
children.exists(index[i])) {
238 current_node->
children.insert(index[i], new_node);
240 new_node->
parent = current_node;
250 template <
typename Key,
typename Data >
262 for (i = 0; i + 1 < index.size(); ++i) {
268 current_node->
children.insert(index[i], new_node);
270 current_node = new_node;
272 current_node = current_node->
children[index[i]];
280 if (i + 1 == index.size()) {
282 if (current_node->
children.exists(index[i])) {
287 node->
data = theData;
292 current_node->
children.insert(index[i], new_node);
293 new_node->
parent = current_node;
306 template <
typename Key,
typename Data >
308 const Data& theData) {
318 for (i = 0; i + 1 < index.size(); ++i) {
324 current_node->
children.insert(index[i], new_node);
326 current_node = new_node;
328 current_node = current_node->
children[index[i]];
336 if (i + 1 == index.size()) {
338 if (current_node->
children.exists(index[i])) {
343 node->
data =
new Data(theData);
348 current_node->
children.insert(index[i], new_node);
349 new_node->
parent = current_node;
356 data =
new Data(theData);
362 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 >
384 for (
unsigned int i = 0; i < index.size(); ++i)
385 current_node = current_node->
children[index[i]];
387 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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
~IndexedTree()
Class destructor.
#define GUM_ERROR(type, msg)