summaryrefslogtreecommitdiffstats
path: root/libcnary/include
diff options
context:
space:
mode:
Diffstat (limited to 'libcnary/include')
-rw-r--r--libcnary/include/node.h42
-rw-r--r--libcnary/include/node_list.h23
2 files changed, 34 insertions, 31 deletions
diff --git a/libcnary/include/node.h b/libcnary/include/node.h
index 7e9da50..123241a 100644
--- a/libcnary/include/node.h
+++ b/libcnary/include/node.h
@@ -24,42 +24,42 @@
24#ifndef NODE_H_ 24#ifndef NODE_H_
25#define NODE_H_ 25#define NODE_H_
26 26
27#include "node_list.h"
27#include "object.h" 28#include "object.h"
28 29
29#define NODE_TYPE 1; 30#define NODE_TYPE 1;
30 31
31struct node_list_t;
32
33// This class implements the abstract iterator class 32// This class implements the abstract iterator class
34typedef struct node_t { 33typedef struct node* node_t;
34struct node {
35 // Super class 35 // Super class
36 struct node_t* next; 36 node_t next;
37 struct node_t* prev; 37 node_t prev;
38 unsigned int count; 38 unsigned int count;
39 39
40 // Local Members 40 // Local Members
41 void *data; 41 void *data;
42 struct node_t* parent; 42 node_t parent;
43 struct node_list_t* children; 43 node_list_t children;
44} node_t; 44};
45 45
46void node_destroy(struct node_t* node); 46void node_destroy(node_t node);
47struct node_t* node_create(struct node_t* parent, void* data); 47node_t node_create(node_t parent, void* data);
48 48
49int node_attach(struct node_t* parent, struct node_t* child); 49int node_attach(node_t parent, node_t child);
50int node_detach(struct node_t* parent, struct node_t* child); 50int node_detach(node_t parent, node_t child);
51int node_insert(struct node_t* parent, unsigned int index, struct node_t* child); 51int node_insert(node_t parent, unsigned int index, node_t child);
52 52
53unsigned int node_n_children(struct node_t* node); 53unsigned int node_n_children(node_t node);
54node_t* node_nth_child(struct node_t* node, unsigned int n); 54node_t node_nth_child(node_t node, unsigned int n);
55node_t* node_first_child(struct node_t* node); 55node_t node_first_child(node_t node);
56node_t* node_prev_sibling(struct node_t* node); 56node_t node_prev_sibling(node_t node);
57node_t* node_next_sibling(struct node_t* node); 57node_t node_next_sibling(node_t node);
58int node_child_position(struct node_t* parent, node_t* child); 58int node_child_position(node_t parent, node_t child);
59 59
60typedef void* (*copy_func_t)(const void *src); 60typedef void* (*copy_func_t)(const void *src);
61node_t* node_copy_deep(node_t* node, copy_func_t copy_func); 61node_t node_copy_deep(node_t node, copy_func_t copy_func);
62 62
63void node_debug(struct node_t* node); 63void node_debug(node_t node);
64 64
65#endif /* NODE_H_ */ 65#endif /* NODE_H_ */
diff --git a/libcnary/include/node_list.h b/libcnary/include/node_list.h
index 380916e..d566b00 100644
--- a/libcnary/include/node_list.h
+++ b/libcnary/include/node_list.h
@@ -24,24 +24,27 @@
24#ifndef NODE_LIST_H_ 24#ifndef NODE_LIST_H_
25#define NODE_LIST_H_ 25#define NODE_LIST_H_
26 26
27struct node_t; 27#include "node.h"
28
29typedef struct node* node_t;
28 30
29// This class implements the list_t abstract class 31// This class implements the list_t abstract class
30typedef struct node_list_t { 32struct node_list {
31 // list_t members 33 // list_t members
32 struct node_t* begin; 34 node_t begin;
33 struct node_t* end; 35 node_t end;
34 36
35 // node_list_t members 37 // node_list_t members
36 unsigned int count; 38 unsigned int count;
37 39
38} node_list_t; 40};
41typedef struct node_list* node_list_t;
39 42
40void node_list_destroy(struct node_list_t* list); 43void node_list_destroy(node_list_t list);
41struct node_list_t* node_list_create(); 44node_list_t node_list_create();
42 45
43int node_list_add(node_list_t* list, node_t* node); 46int node_list_add(node_list_t list, node_t node);
44int node_list_insert(node_list_t* list, unsigned int index, node_t* node); 47int node_list_insert(node_list_t list, unsigned int index, node_t node);
45int node_list_remove(node_list_t* list, node_t* node); 48int node_list_remove(node_list_t list, node_t node);
46 49
47#endif /* NODE_LIST_H_ */ 50#endif /* NODE_LIST_H_ */