![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
The class for storing the nodes of the Arborescence. More...
#include <agrum/tools/core/indexedTree.h>
Public Member Functions | |
Constructors / Destructors | |
IndexedTree (Data *data=nullptr) | |
Creates a tree with one node with or without data. More... | |
IndexedTree (const Key &theKey, Data *data=nullptr) | |
Creates a tree with one node (with or without data). More... | |
IndexedTree (const Key &theKey, const Data &data) | |
Creates a tree with one node with data. More... | |
IndexedTree (const IndexedTree< Key, Data > &from) | |
Copy constructor. More... | |
IndexedTree< Key, Data > & | operator= (const IndexedTree< Key, Data > &from) |
Copy operator. More... | |
~IndexedTree () | |
Class destructor. More... | |
Accessors / Modifiers | |
void | insertNode (const std::vector< Key > &index, const Data *data) |
Adds a new node into the tree. More... | |
void | insertNode (const std::vector< Key > &index, const Data &data) |
Adds a new node into the tree. More... | |
void | setNode (const std::vector< Key > &index, Data *data) |
Updates the value of a node (or adds it if it does not already exist). More... | |
void | setNode (const std::vector< Key > &index, const Data &data) |
Updates the value of a node (or adds it if it does not already exist). More... | |
Data & | getData (const std::vector< Key > &index) const |
Returns the value of a given node of the tree. More... | |
IndexedTree< Key, Data > & | getNode (const std::vector< Key > &index) const |
Returns a given node of the tree. More... | |
The class for storing the nodes of the Arborescence.
Key | The tree's keys type. |
Data | The tree's values type. |
Definition at line 52 of file indexedTree.h.
gum::IndexedTree< Key, Data >::IndexedTree | ( | Data * | data = nullptr | ) |
Creates a tree with one node with or without data.
If data equals the nullptr, then tree is created with one node without data.
data | Adds data as the root of the tree. |
Definition at line 51 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
gum::IndexedTree< Key, Data >::IndexedTree | ( | const Key & | theKey, |
Data * | data = nullptr |
||
) |
Creates a tree with one node (with or without data).
The parameters are inserted directly into the tree, i.e., no copy is performed. For copies of key and data to occur, use the constructor with const& parameters.
If data equals the nullptr, then tree is created with one node without data.
theKey | The data's key. |
data | The data added to the tree. |
Definition at line 42 of file indexedTree_tpl.h.
gum::IndexedTree< Key, Data >::IndexedTree | ( | const Key & | theKey, |
const Data & | data | ||
) |
Creates a tree with one node with data.
The key and data are copied into the tree. If you do not want any copy, use the constructor with the pointers parameters.
theKey | The data's key. |
data | The data added to the tree. |
Definition at line 59 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
gum::IndexedTree< Key, Data >::IndexedTree | ( | const IndexedTree< Key, Data > & | from | ) |
Copy constructor.
from | The gum::IndexedTree to copy. |
Definition at line 68 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
gum::IndexedTree< Key, Data >::~IndexedTree | ( | ) |
Class destructor.
Definition at line 134 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE Data & gum::IndexedTree< Key, Data >::getData | ( | const std::vector< Key > & | index | ) | const |
Returns the value of a given node of the tree.
index | The node's index. |
NotFound | exception is thrown if the so-called value cannot be found in the tree. |
Definition at line 349 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE IndexedTree< Key, Data > & gum::IndexedTree< Key, Data >::getNode | ( | const std::vector< Key > & | index | ) | const |
Returns a given node of the tree.
index | The node's index. |
NotFound | exception is thrown if the node we look for cannot be found in the tree. |
Definition at line 364 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
void gum::IndexedTree< Key, Data >::insertNode | ( | const std::vector< Key > & | index, |
const Data * | data | ||
) |
Adds a new node into the tree.
index | The node's index. |
data | The node's data. |
DuplicateElement | exception is thrown if a node with an identical index has already been entered into the tree. If, in this case, you would like the value of the to be updated, use function setNode instead. |
Definition at line 144 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
void gum::IndexedTree< Key, Data >::insertNode | ( | const std::vector< Key > & | index, |
const Data & | data | ||
) |
Adds a new node into the tree.
index | The node's index. |
data | The node's data. |
DuplicateElement | exception is thrown if a node with an identical index has already been entered into the tree. If, in this case, you would like the value of the to be updated, use function setNode instead. |
Definition at line 194 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
IndexedTree< Key, Data > & gum::IndexedTree< Key, Data >::operator= | ( | const IndexedTree< Key, Data > & | from | ) |
Copy operator.
from | The gum::IndexedTree to copy. |
Definition at line 97 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
void gum::IndexedTree< Key, Data >::setNode | ( | const std::vector< Key > & | index, |
Data * | data | ||
) |
Updates the value of a node (or adds it if it does not already exist).
index | The node's index. |
data | The node's data. |
Definition at line 243 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
void gum::IndexedTree< Key, Data >::setNode | ( | const std::vector< Key > & | index, |
const Data & | data | ||
) |
Updates the value of a node (or adds it if it does not already exist).
index | The node's index. |
data | The node's data. |
Definition at line 296 of file indexedTree_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
The list of children nodes of the current node.
Definition at line 191 of file indexedTree.h.
|
private |
The data stored into the node.
Definition at line 185 of file indexedTree.h.
|
private |
The key of the current node.
Definition at line 182 of file indexedTree.h.
|
private |
The parent of the node.
Definition at line 188 of file indexedTree.h.