ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
ParentTree.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*--------------------------- File ParentTree.h ----------------------------*/
3
/*--------------------------------------------------------------------------*/
27
/*--------------------------------------------------------------------------*/
28
/*----------------------------- DEFINITIONS --------------------------------*/
29
/*--------------------------------------------------------------------------*/
30
31
#ifndef __ADS_ParentTree
32
#define __ADS_ParentTree
33
/* self-identification: #endif constant */
34
35
/*--------------------------------------------------------------------------*/
36
/*------------------------------ INCLUDES ----------------------------------*/
37
/*--------------------------------------------------------------------------*/
38
39
#include "
ADS/Contract.h
"
40
41
#include <vector>
42
43
/*--------------------------------------------------------------------------*/
44
/*--------------------------- NAMESPACE ------------------------------------*/
45
/*--------------------------------------------------------------------------*/
46
47
namespace
ADS
48
{
49
50
/*--------------------------------------------------------------------------*/
51
/*-------------------------- CLASS ParentTree ------------------------------*/
52
/*--------------------------------------------------------------------------*/
53
56
class
ParentTree
57
{
58
59
/*--------------------------------------------------------------------------*/
60
public
:
63
explicit
ParentTree
(
int
n );
64
67
[[nodiscard]]
int
parent
(
int
i )
const
;
68
91
void
setParent
(
int
i ,
int
j );
92
94
[[nodiscard]]
int
size
(
void
)
const
;
95
96
/*--------------------------------------------------------------------------*/
97
private
:
100
[[nodiscard]]
bool
below(
int
j ,
int
i )
const
;
101
102
std::vector< int > f_p;
103
104
};
// end( class ParentTree )
105
106
/*--------------------------------------------------------------------------*/
107
108
}
// end( namespace ADS )
109
110
/*--------------------------------------------------------------------------*/
111
/*-------------------------- IMPLEMENTATION --------------------------------*/
112
/*--------------------------------------------------------------------------*/
113
114
#include "ADS/tree/impl/ParentTree.tpp"
115
116
/*--------------------------------------------------------------------------*/
117
118
#endif
/* ParentTree.h included */
119
120
/*--------------------------------------------------------------------------*/
121
/*------------------------- End File ParentTree.h --------------------------*/
122
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::ParentTree::parent
int parent(int i) const
the parent of the node ; -1 if is a root
ADS::ParentTree::ParentTree
ParentTree(int n)
a forest of isolated nodes (the Tree( n ) of the book)
ADS::ParentTree::size
int size(void) const
the number of nodes
ADS::ParentTree::setParent
void setParent(int i, int j)
makes the node a child of the node , or a root if , in (section 5.4, )
ADS
Definition
ADT.h:96
ADS
tree
ParentTree.h
Generated by
1.17.0