Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Binary_Tree.h
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 
25 #ifndef BINARY_TREE_H
26 #define BINARY_TREE_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
37 {
38  int rank;
39  int size;
40  int left_child;
42  int parent;
43 };
44 
45 
52 void Binary_Tree_init(struct Binary_Tree *bt, int rank, int size);
53 
58 void Binary_Tree_release(struct Binary_Tree *bt);
59 
65 static inline int Binary_Tree_parent(struct Binary_Tree *bt)
66 {
67  return bt->parent;
68 }
69 
75 static inline int Binary_Tree_left_child(struct Binary_Tree *bt)
76 {
77  return bt->left_child;
78 }
79 
85 static inline int Binary_Tree_right_child(struct Binary_Tree *bt)
86 {
87  return bt->right_child;
88 }
89 
90 static inline int Binary_Tree_child_count(struct Binary_Tree *bt)
91 {
92  int ret = 0;
93 
94  if( 0 <= Binary_Tree_left_child(bt) )
95  ret ++;
96 
97  if( 0 <= Binary_Tree_right_child(bt) )
98  ret ++;
99 
100  return ret;
101 }
102 
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 
109 #endif /* BINARY_TREE_H */
110 
int parent
The rank of the parent.
Definition: Binary_Tree.h:42
void Binary_Tree_init(struct Binary_Tree *bt, int rank, int size)
Initialization of a binary tree.
Definition: Binary_Tree.c:22
int rank
The rank of the element.
Definition: Binary_Tree.h:38
static int Binary_Tree_right_child(struct Binary_Tree *bt)
Getter on the right child.
Definition: Binary_Tree.h:85
Struct defining a binary tree.
Definition: Binary_Tree.h:36
static int Binary_Tree_parent(struct Binary_Tree *bt)
Getter on the parent.
Definition: Binary_Tree.h:65
static int Binary_Tree_left_child(struct Binary_Tree *bt)
Getter on the left child.
Definition: Binary_Tree.h:75
static int Binary_Tree_child_count(struct Binary_Tree *bt)
Definition: Binary_Tree.h:90
int right_child
The rank of the right child.
Definition: Binary_Tree.h:41
void Binary_Tree_release(struct Binary_Tree *bt)
releases a binary tree
Definition: Binary_Tree.c:67
int size
The size of the element.
Definition: Binary_Tree.h:39
int left_child
The rank of the left child.
Definition: Binary_Tree.h:40