ds: tree: convert to new object system
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
#ifndef BLUELIB_TREE_H_
|
||||
#define BLUELIB_TREE_H_
|
||||
#ifndef BLUE_DS_TREE_H_
|
||||
#define BLUE_DS_TREE_H_
|
||||
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/queue.h>
|
||||
#include <blue/ds/string.h>
|
||||
|
||||
#define B_TREE(p) ((b_tree *)(p))
|
||||
#define B_TREE_NODE_INIT ((b_tree_node){0})
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_TREE (b_tree_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_tree);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_tree)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_tree)
|
||||
|
||||
#define B_TREE_NODE_INIT ((b_tree_node) {0})
|
||||
|
||||
#define B_TREE_CONTAINER(t, m, v) \
|
||||
((void *)((v) ? (uintptr_t)(v) - (offsetof(t, m)) : 0))
|
||||
|
||||
typedef struct b_tree b_tree;
|
||||
|
||||
#define b_tree_node_foreach(it, node) \
|
||||
for (int z__b_unique_name() = b_tree_iterator_begin_at_node(node, it); \
|
||||
(it)->node != NULL; b_tree_iterator_next(it))
|
||||
@@ -29,8 +36,6 @@ typedef struct b_tree b_tree;
|
||||
typedef struct b_tree_node {
|
||||
struct b_tree_node *__p01, *__p02, *__p03;
|
||||
struct b_queue_entry __q01;
|
||||
// struct b_tree_node *parent;
|
||||
// struct b_tree_node *first_child, *next_sibling;
|
||||
} b_tree_node;
|
||||
|
||||
typedef struct b_tree_iterator {
|
||||
@@ -41,16 +46,9 @@ typedef struct b_tree_iterator {
|
||||
unsigned char _f01;
|
||||
} b_tree_iterator;
|
||||
|
||||
BLUE_API b_tree *b_tree_create(void);
|
||||
BLUE_API b_type b_tree_get_type(void);
|
||||
|
||||
static inline b_tree *b_tree_retain(b_tree *tree)
|
||||
{
|
||||
return B_TREE(b_retain(B_DSREF(tree)));
|
||||
}
|
||||
static inline void b_tree_release(b_tree *tree)
|
||||
{
|
||||
b_release(B_DSREF(tree));
|
||||
}
|
||||
B_TYPE_DEFAULT_CONSTRUCTOR(b_tree, B_TYPE_TREE);
|
||||
|
||||
BLUE_API void b_tree_set_root(b_tree *tree, struct b_tree_node *node);
|
||||
|
||||
@@ -69,4 +67,6 @@ BLUE_API bool b_tree_iterator_next(b_tree_iterator *it);
|
||||
BLUE_API b_status b_tree_iterator_erase(b_tree_iterator *it);
|
||||
BLUE_API bool b_tree_iterator_is_valid(const b_tree_iterator *it);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user