GL4Dummies  0.1.7
Référence du fichier bin_tree.h

Fonctions de gestion d'arbres binaires. Plus de détails...

#include "gl4dummies.h"
Graphe des dépendances par inclusion de bin_tree.h:
Ce graphe montre quels fichiers incluent directement ou indirectement ce fichier :

Aller au code source de ce fichier.

Structures de données

struct  pair_t
 
struct  bin_tree_t
 

Macros

#define STRUCT_PAIR_T
 

Définitions de type

typedef struct bin_tree_t bin_tree_t
 
typedef struct pair_t pair_t
 

Fonctions

GL4DAPI pair_t GL4DAPIENTRY btInsert (bin_tree_t **tree, void *data, int(*compar)(const void *newData, const void *nodeData))
 
GL4DAPI pair_t GL4DAPIENTRY btFind (bin_tree_t **tree, const void *data, int(*compar)(const void *newData, const void *nodeData))
 
GL4DAPI bin_tree_t **GL4DAPIENTRY btFirst (bin_tree_t **ptr)
 
GL4DAPI bin_tree_t **GL4DAPIENTRY btLast (bin_tree_t **ptr)
 
GL4DAPI void GL4DAPIENTRY btDelete (bin_tree_t **ptr, void(GL4DAPIENTRY *freeData)(void *))
 
GL4DAPI bin_tree_t **GL4DAPIENTRY btNext (bin_tree_t **ptr)
 
GL4DAPI void GL4DAPIENTRY btFree (bin_tree_t **tree, void(GL4DAPIENTRY *freeData)(void *))
 
GL4DAPI void GL4DAPIENTRY btForAll (bin_tree_t *ptr, void(*todo)(void *, void **), void **ldata)
 

Description détaillée

Fonctions de gestion d'arbres binaires.

Auteur
Fares BELHADJ amsi@.nosp@m.ai.u.nosp@m.niv-p.nosp@m.aris.nosp@m.8.fr
Date
January 16, 2006

Définition dans le fichier bin_tree.h.

Documentation des macros

◆ STRUCT_PAIR_T

#define STRUCT_PAIR_T

Documentation des définitions de type

◆ bin_tree_t

typedef struct bin_tree_t bin_tree_t

◆ pair_t

typedef struct pair_t pair_t

Documentation des fonctions

◆ btDelete()

GL4DAPI void GL4DAPIENTRY btDelete ( bin_tree_t **  ptr,
void(GL4DAPIENTRY *freeData)(void *)   
)

◆ btFind()

GL4DAPI pair_t GL4DAPIENTRY btFind ( bin_tree_t **  tree,
const void *  data,
int(*)(const void *newData, const void *nodeData)  compar 
)
32  {
33  pair_t res = {(void **)tree, -1};
34  while(*((bin_tree_t **)res.ptr)) {
35  if((res.compResult = compar(data, (*((bin_tree_t **)res.ptr))->data)) < 0)
36  res.ptr = (void **)&((*((bin_tree_t **)res.ptr))->lc);
37  else if(res.compResult > 0)
38  res.ptr = (void **)&((*((bin_tree_t **)res.ptr))->rc);
39  else
40  return res;
41  }
42  return res;
43 }

Références pair_t::compResult, et pair_t::ptr.

Référencé par findMatrix(), gl4duGenMatrix(), gl4duIsMatrix(), gl4duwBindWindow(), gl4duwCreateWindow(), et manageEvents().

◆ btFirst()

GL4DAPI bin_tree_t** GL4DAPIENTRY btFirst ( bin_tree_t **  ptr)
45  {
46  bin_tree_t ** f = ptr;
47  while(*ptr) {
48  f = ptr;
49  ptr = &((*ptr)->lc);
50  }
51  return f;
52 }

Référencé par btNext().

◆ btForAll()

GL4DAPI void GL4DAPIENTRY btForAll ( bin_tree_t ptr,
void(*)(void *, void **)  todo,
void **  ldata 
)
113  {
114  if(ptr->lc)
115  btForAll(ptr->lc, todo, ldata);
116  todo(ptr->data, ldata);
117  if(ptr->rc)
118  btForAll(ptr->rc, todo, ldata);
119 }

Références btForAll(), bin_tree_t::data, bin_tree_t::lc, et bin_tree_t::rc.

Référencé par btForAll(), gl4duSendMatrices(), et gl4duwMainLoop().

◆ btFree()

GL4DAPI void GL4DAPIENTRY btFree ( bin_tree_t **  tree,
void(GL4DAPIENTRY *freeData)(void *)   
)

◆ btInsert()

GL4DAPI pair_t GL4DAPIENTRY btInsert ( bin_tree_t **  tree,
void *  data,
int(*)(const void *newData, const void *nodeData)  compar 
)
13  {
14  bin_tree_t ** next = *tree ? (*tree)->next : NULL /* correspond au parent du dernier fils gauche */;
15  pair_t res = {(void **)tree, -1};
16  while(*((bin_tree_t **)res.ptr)) {
17  if((res.compResult = compar(data, (*((bin_tree_t **)res.ptr))->data)) < 0) {
18  next = (bin_tree_t **)res.ptr;
19  res.ptr = (void **)&((*((bin_tree_t **)res.ptr))->lc);
20  } else if(res.compResult > 0) {
21  res.ptr = (void **)&((*((bin_tree_t **)res.ptr))->rc);
22  } else
23  return res;
24  }
25  (*((bin_tree_t **)res.ptr)) = calloc(1, sizeof (bin_tree_t));
26  assert(*res.ptr);
27  (*((bin_tree_t **)res.ptr))->data = data;
28  (*((bin_tree_t **)res.ptr))->next = next;
29  return res;
30 }

Références pair_t::compResult, bin_tree_t::next, et pair_t::ptr.

Référencé par gl4duGenMatrix(), et gl4duwCreateWindow().

◆ btLast()

GL4DAPI bin_tree_t** GL4DAPIENTRY btLast ( bin_tree_t **  ptr)
54  {
55  bin_tree_t ** l = ptr;
56  while(*ptr) {
57  l = ptr;
58  ptr = &((*ptr)->rc);
59  }
60  return l;
61 }

◆ btNext()

GL4DAPI bin_tree_t** GL4DAPIENTRY btNext ( bin_tree_t **  ptr)
100  {
101  return (*ptr)->rc ? btFirst(&((*ptr)->rc)) : (*ptr)->next;
102 }

Références btFirst(), bin_tree_t::next, et bin_tree_t::rc.

pair_t::ptr
void ** ptr
Definition: bin_tree.h:23
bin_tree_t::lc
struct bin_tree_t * lc
Definition: bin_tree.h:30
bin_tree_t::rc
struct bin_tree_t * rc
Definition: bin_tree.h:30
bin_tree_t::next
struct bin_tree_t ** next
Definition: bin_tree.h:30
bin_tree_t::data
void * data
Definition: bin_tree.h:29
bin_tree_t
Definition: bin_tree.h:28
btFirst
bin_tree_t ** btFirst(bin_tree_t **ptr)
Definition: bin_tree.c:45
pair_t
Definition: bin_tree.h:22
pair_t::compResult
int compResult
Definition: bin_tree.h:24
btForAll
void btForAll(bin_tree_t *ptr, void(*todo)(void *, void **), void **ldata)
Definition: bin_tree.c:113