aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
indexedTree.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 by *
5
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
6
* - Christophe GONZALES(_at_AMU) *
7
* *
8
* The aGrUM/pyAgrum library is free software; you can redistribute it *
9
* and/or modify it under the terms of either : *
10
* *
11
* - the GNU Lesser General Public License as published by *
12
* the Free Software Foundation, either version 3 of the License, *
13
* or (at your option) any later version, *
14
* - the MIT license (MIT), *
15
* - or both in dual license, as here. *
16
* *
17
* (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18
* *
19
* This aGrUM/pyAgrum library is distributed in the hope that it will be *
20
* useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26
* OTHER DEALINGS IN THE SOFTWARE. *
27
* *
28
* See LICENCES for more details. *
29
* *
30
* SPDX-FileCopyrightText: Copyright 2005-2026 *
31
* - Pierre-Henri WUILLEMIN(_at_LIP6) *
32
* - Christophe GONZALES(_at_AMU) *
33
* SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34
* *
35
* Contact : info_at_agrum_dot_org *
36
* homepage : http://agrum.gitlab.io *
37
* gitlab : https://gitlab.com/agrumery/agrum *
38
* *
39
****************************************************************************/
40
41
48
#ifndef GUM_INDEXED_TREE_H
49
#define GUM_INDEXED_TREE_H
50
51
#include <iostream>
52
53
#include <
agrum/agrum.h
>
54
55
#include <
agrum/base/core/hashTable.h
>
56
57
namespace
gum
{
58
59
// =========================================================================
60
// === NODES FOR GENERIC TREE (DATA) STRUCTURE === */
61
// =========================================================================
62
72
template
<
typename
Key,
typename
Data >
73
class
IndexedTree
{
74
public
:
75
// ============================================================================
77
// ============================================================================
79
88
IndexedTree
(Data*
data
=
nullptr
);
89
103
IndexedTree
(
const
Key& theKey, Data*
data
=
nullptr
);
104
114
IndexedTree
(
const
Key& theKey,
const
Data&
data
);
115
120
IndexedTree
(
const
IndexedTree< Key, Data >
& from);
121
127
IndexedTree< Key, Data >
&
operator=
(
const
IndexedTree< Key, Data >
& from);
128
132
~IndexedTree
();
133
135
// ============================================================================
137
// ============================================================================
139
149
void
insertNode
(
const
std::vector< Key >& index,
const
Data*
data
);
150
160
void
insertNode
(
const
std::vector< Key >& index,
const
Data&
data
);
161
169
void
setNode
(
const
std::vector< Key >& index, Data*
data
);
170
178
void
setNode
(
const
std::vector< Key >& index,
const
Data&
data
);
179
188
Data&
getData
(
const
std::vector< Key >& index)
const
;
189
197
IndexedTree< Key, Data >
&
getNode
(
const
std::vector< Key >& index)
const
;
198
200
201
private
:
203
Key
key
;
204
206
Data*
data
;
207
209
IndexedTree< Key, Data >
*
parent
;
210
212
HashTable< Key, IndexedTree< Key, Data >
* >
children
;
213
};
214
216
template
<
typename
Key,
typename
Data >
217
std::ostream&
operator<<
(std::ostream&,
const
IndexedTree< Key, Data >
&);
218
219
}
/* namespace gum */
220
221
// always include the templated implementations
222
#include <
agrum/base/core/indexedTree_tpl.h
>
223
224
#endif
/* GUM_INDEXED_TREE_H */
agrum.h
gum::HashTable
The class for generic Hash Tables.
Definition
hashTable.h:640
gum::IndexedTree
The class for storing the nodes of the Arborescence.
Definition
indexedTree.h:73
gum::IndexedTree::insertNode
void insertNode(const std::vector< Key > &index, const Data *data)
Adds a new node into the tree.
Definition
indexedTree_tpl.h:164
gum::IndexedTree::data
Data * data
The data stored into the node.
Definition
indexedTree.h:206
gum::IndexedTree::getNode
IndexedTree< Key, Data > & getNode(const std::vector< Key > &index) const
Returns a given node of the tree.
Definition
indexedTree_tpl.h:380
gum::IndexedTree::setNode
void setNode(const std::vector< Key > &index, Data *data)
Updates the value of a node (or adds it if it does not already exist).
Definition
indexedTree_tpl.h:261
gum::IndexedTree::children
HashTable< Key, IndexedTree< Key, Data > * > children
The list of children nodes of the current node.
Definition
indexedTree.h:212
gum::IndexedTree::key
Key key
The key of the current node.
Definition
indexedTree.h:203
gum::IndexedTree::getData
Data & getData(const std::vector< Key > &index) const
Returns the value of a given node of the tree.
Definition
indexedTree_tpl.h:365
gum::IndexedTree::parent
IndexedTree< Key, Data > * parent
The parent of the node.
Definition
indexedTree.h:209
gum::IndexedTree::operator=
IndexedTree< Key, Data > & operator=(const IndexedTree< Key, Data > &from)
Copy operator.
Definition
indexedTree_tpl.h:119
gum::IndexedTree::IndexedTree
IndexedTree(Data *data=nullptr)
Creates a tree with one node with or without data.
Definition
indexedTree_tpl.h:73
hashTable.h
Class hash tables iterators.
indexedTree_tpl.h
Implementation of tree data structures.
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::operator<<
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0