current version
[opsoft_test.git] / gclib2 / include / Tree.h
blob7d8d4bbc425db2a5bcc998a557da98e653b24e16
1 /*
2 * (c) Oleg Puchinin 2007
3 * graycardinalster@gmail.com
5 */
7 #ifndef DEFINE_TREE_H
8 #define DEFINE_TREE_H
10 #include "elist.h"
11 struct node_t;
12 struct node_t
14 char * key;
15 char * userData;
16 uint32_t ID;
17 node_t * parentNode;
18 List * childNodes; // node_t *
21 typedef void (node_f) (node_t *);
23 /// Класс - дерево.
24 class Tree
26 public:
27 Tree ();
28 ~Tree ();
30 node_t * rootNode;
31 char * userData;
33 node_t * newNode (node_t * parent, char * key = NULL, char * userData = NULL);
34 char * freeNode (node_t * node, Dfunc_t f);
35 List * childs (node_t * node);
36 node_t * searchDown (node_t * node, char *key, uint32_t ID = 0);
37 node_t * searchUp (node_t * node, char *key, uint32_t ID = 0);
38 List * keyChilds (node_t * node, char * key, uint32_t ID = 0);
39 void foreach (node_f fn, node_t * m_node = NULL);
41 private:
42 uint16_t lastID;
45 #endif