ds: update references to fx_btree
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include <fx/core/btree.h>
|
||||
#include <fx/core/bst.h>
|
||||
#include <fx/core/iterator.h>
|
||||
#include <fx/ds/dict.h>
|
||||
#include <fx/ds/number.h>
|
||||
@@ -12,13 +12,13 @@ struct tree_item {
|
||||
fx_tree_node node;
|
||||
};
|
||||
|
||||
struct btree_item {
|
||||
struct bst_item {
|
||||
int value;
|
||||
fx_bst_node node;
|
||||
};
|
||||
|
||||
FX_BTREE_DEFINE_SIMPLE_GET(struct btree_item, int, node, value, get_node)
|
||||
FX_BTREE_DEFINE_SIMPLE_INSERT(struct btree_item, node, value, put_node)
|
||||
FX_BST_DEFINE_SIMPLE_GET(struct bst_item, int, node, value, get_node)
|
||||
FX_BST_DEFINE_SIMPLE_INSERT(struct bst_item, node, value, put_node)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -71,19 +71,19 @@ int main(void)
|
||||
printf("%u\n", item->value);
|
||||
}
|
||||
|
||||
fx_bst btree = {0};
|
||||
struct btree_item items3[NITEMS] = {0};
|
||||
fx_bst bst = {0};
|
||||
struct bst_item items3[NITEMS] = {0};
|
||||
for (int i = 0; i < NITEMS; i++) {
|
||||
items3[i].value = i;
|
||||
put_node(&btree, &items3[i]);
|
||||
put_node(&bst, &items3[i]);
|
||||
}
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
fx_bst_iterator it3;
|
||||
fx_bst_foreach (&it3, &btree) {
|
||||
struct btree_item *item
|
||||
= fx_unbox(struct btree_item, it3.node, node);
|
||||
fx_bst_foreach (&it3, &bst) {
|
||||
struct bst_item *item
|
||||
= fx_unbox(struct bst_item, it3.node, node);
|
||||
|
||||
for (size_t i = 0; i < it3.depth; i++) {
|
||||
fputs(" ", stdout);
|
||||
@@ -92,10 +92,10 @@ int main(void)
|
||||
printf("%d\n", item->value);
|
||||
}
|
||||
|
||||
fx_bst_iterator_begin(&btree, &it3);
|
||||
fx_bst_iterator_begin(&bst, &it3);
|
||||
while (fx_bst_iterator_is_valid(&it3)) {
|
||||
struct btree_item *item
|
||||
= fx_unbox(struct btree_item, it3.node, node);
|
||||
struct bst_item *item
|
||||
= fx_unbox(struct bst_item, it3.node, node);
|
||||
|
||||
if (item->value == 9) {
|
||||
fx_bst_iterator_erase(&it3);
|
||||
@@ -106,9 +106,9 @@ int main(void)
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
fx_bst_foreach (&it3, &btree) {
|
||||
struct btree_item *item
|
||||
= fx_unbox(struct btree_item, it3.node, node);
|
||||
fx_bst_foreach (&it3, &bst) {
|
||||
struct bst_item *item
|
||||
= fx_unbox(struct bst_item, it3.node, node);
|
||||
|
||||
for (size_t i = 0; i < it3.depth; i++) {
|
||||
fputs(" ", stdout);
|
||||
|
||||
Reference in New Issue
Block a user