diff options
| author | 2023-02-06 18:28:28 +0100 | |
|---|---|---|
| committer | 2023-02-06 18:28:28 +0100 | |
| commit | d3908006349f38bcfc0151daebd98b6873a2dbfc (patch) | |
| tree | 238072fa5380039ad29af87c0d6e618ab37d4d5b /libcnary/include | |
| parent | 52826a6c229ed3e353d4dae711a6c52a96d99764 (diff) | |
| download | libplist-d3908006349f38bcfc0151daebd98b6873a2dbfc.tar.gz libplist-d3908006349f38bcfc0151daebd98b6873a2dbfc.tar.bz2 | |
libcnary: Updated typedefs of node_t and node_list_t to contain pointer
This makes the code more readable. Obviously all the code that uses it
is also updated.
Diffstat (limited to 'libcnary/include')
| -rw-r--r-- | libcnary/include/node.h | 42 | ||||
| -rw-r--r-- | libcnary/include/node_list.h | 23 |
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 | ||
| 31 | struct node_list_t; | ||
| 32 | |||
| 33 | // This class implements the abstract iterator class | 32 | // This class implements the abstract iterator class |
| 34 | typedef struct node_t { | 33 | typedef struct node* node_t; |
| 34 | struct 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 | ||
| 46 | void node_destroy(struct node_t* node); | 46 | void node_destroy(node_t node); |
| 47 | struct node_t* node_create(struct node_t* parent, void* data); | 47 | node_t node_create(node_t parent, void* data); |
| 48 | 48 | ||
| 49 | int node_attach(struct node_t* parent, struct node_t* child); | 49 | int node_attach(node_t parent, node_t child); |
| 50 | int node_detach(struct node_t* parent, struct node_t* child); | 50 | int node_detach(node_t parent, node_t child); |
| 51 | int node_insert(struct node_t* parent, unsigned int index, struct node_t* child); | 51 | int node_insert(node_t parent, unsigned int index, node_t child); |
| 52 | 52 | ||
| 53 | unsigned int node_n_children(struct node_t* node); | 53 | unsigned int node_n_children(node_t node); |
| 54 | node_t* node_nth_child(struct node_t* node, unsigned int n); | 54 | node_t node_nth_child(node_t node, unsigned int n); |
| 55 | node_t* node_first_child(struct node_t* node); | 55 | node_t node_first_child(node_t node); |
| 56 | node_t* node_prev_sibling(struct node_t* node); | 56 | node_t node_prev_sibling(node_t node); |
| 57 | node_t* node_next_sibling(struct node_t* node); | 57 | node_t node_next_sibling(node_t node); |
| 58 | int node_child_position(struct node_t* parent, node_t* child); | 58 | int node_child_position(node_t parent, node_t child); |
| 59 | 59 | ||
| 60 | typedef void* (*copy_func_t)(const void *src); | 60 | typedef void* (*copy_func_t)(const void *src); |
| 61 | node_t* node_copy_deep(node_t* node, copy_func_t copy_func); | 61 | node_t node_copy_deep(node_t node, copy_func_t copy_func); |
| 62 | 62 | ||
| 63 | void node_debug(struct node_t* node); | 63 | void 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 | ||
| 27 | struct node_t; | 27 | #include "node.h" |
| 28 | |||
| 29 | typedef struct node* node_t; | ||
| 28 | 30 | ||
| 29 | // This class implements the list_t abstract class | 31 | // This class implements the list_t abstract class |
| 30 | typedef struct node_list_t { | 32 | struct 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 | }; |
| 41 | typedef struct node_list* node_list_t; | ||
| 39 | 42 | ||
| 40 | void node_list_destroy(struct node_list_t* list); | 43 | void node_list_destroy(node_list_t list); |
| 41 | struct node_list_t* node_list_create(); | 44 | node_list_t node_list_create(); |
| 42 | 45 | ||
| 43 | int node_list_add(node_list_t* list, node_t* node); | 46 | int node_list_add(node_list_t list, node_t node); |
| 44 | int node_list_insert(node_list_t* list, unsigned int index, node_t* node); | 47 | int node_list_insert(node_list_t list, unsigned int index, node_t node); |
| 45 | int node_list_remove(node_list_t* list, node_t* node); | 48 | int node_list_remove(node_list_t list, node_t node); |
| 46 | 49 | ||
| 47 | #endif /* NODE_LIST_H_ */ | 50 | #endif /* NODE_LIST_H_ */ |
