ds: update references to fx_btree
This commit is contained in:
@@ -38,9 +38,9 @@ struct fx_dict_iterator_p {
|
|||||||
|
|
||||||
/*** MISC FUNCTIONS ***********************************************************/
|
/*** MISC FUNCTIONS ***********************************************************/
|
||||||
|
|
||||||
static FX_BTREE_DEFINE_SIMPLE_GET(
|
static FX_BST_DEFINE_SIMPLE_GET(
|
||||||
struct fx_dict_bucket, uint64_t, bk_node, bk_hash, get_bucket);
|
struct fx_dict_bucket, uint64_t, bk_node, bk_hash, get_bucket);
|
||||||
static FX_BTREE_DEFINE_SIMPLE_INSERT(
|
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||||
struct fx_dict_bucket, bk_node, bk_hash, put_bucket);
|
struct fx_dict_bucket, bk_node, bk_hash, put_bucket);
|
||||||
|
|
||||||
uint64_t fx_cstr_hash(const char *s)
|
uint64_t fx_cstr_hash(const char *s)
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ struct fx_hashmap_iterator_p {
|
|||||||
|
|
||||||
/*** PRIVATE FUNCTIONS ********************************************************/
|
/*** PRIVATE FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
static FX_BTREE_DEFINE_SIMPLE_GET(
|
static FX_BST_DEFINE_SIMPLE_GET(
|
||||||
struct fx_hashmap_bucket, uint64_t, bk_node, bk_hash, get_bucket);
|
struct fx_hashmap_bucket, uint64_t, bk_node, bk_hash, get_bucket);
|
||||||
static FX_BTREE_DEFINE_SIMPLE_INSERT(
|
static FX_BST_DEFINE_SIMPLE_INSERT(
|
||||||
struct fx_hashmap_bucket, bk_node, bk_hash, put_bucket);
|
struct fx_hashmap_bucket, bk_node, bk_hash, put_bucket);
|
||||||
|
|
||||||
static uint64_t hash_data(const void *p, size_t size)
|
static uint64_t hash_data(const void *p, size_t size)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef FX_DS_DICT_H_
|
#ifndef FX_DS_DICT_H_
|
||||||
#define FX_DS_DICT_H_
|
#define FX_DS_DICT_H_
|
||||||
|
|
||||||
#include <fx/core/btree.h>
|
#include <fx/core/bst.h>
|
||||||
#include <fx/core/macros.h>
|
#include <fx/core/macros.h>
|
||||||
#include <fx/core/misc.h>
|
#include <fx/core/misc.h>
|
||||||
#include <fx/core/queue.h>
|
#include <fx/core/queue.h>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef FX_DS_HASHMAP_H_
|
#ifndef FX_DS_HASHMAP_H_
|
||||||
#define FX_DS_HASHMAP_H_
|
#define FX_DS_HASHMAP_H_
|
||||||
|
|
||||||
#include <fx/core/btree.h>
|
#include <fx/core/bst.h>
|
||||||
#include <fx/core/macros.h>
|
#include <fx/core/macros.h>
|
||||||
#include <fx/core/misc.h>
|
#include <fx/core/misc.h>
|
||||||
#include <fx/core/queue.h>
|
#include <fx/core/queue.h>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <fx/core/btree.h>
|
#include <fx/core/bst.h>
|
||||||
#include <fx/core/iterator.h>
|
#include <fx/core/iterator.h>
|
||||||
#include <fx/ds/dict.h>
|
#include <fx/ds/dict.h>
|
||||||
#include <fx/ds/number.h>
|
#include <fx/ds/number.h>
|
||||||
@@ -12,13 +12,13 @@ struct tree_item {
|
|||||||
fx_tree_node node;
|
fx_tree_node node;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct btree_item {
|
struct bst_item {
|
||||||
int value;
|
int value;
|
||||||
fx_bst_node node;
|
fx_bst_node node;
|
||||||
};
|
};
|
||||||
|
|
||||||
FX_BTREE_DEFINE_SIMPLE_GET(struct btree_item, int, node, value, get_node)
|
FX_BST_DEFINE_SIMPLE_GET(struct bst_item, int, node, value, get_node)
|
||||||
FX_BTREE_DEFINE_SIMPLE_INSERT(struct btree_item, node, value, put_node)
|
FX_BST_DEFINE_SIMPLE_INSERT(struct bst_item, node, value, put_node)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@@ -71,19 +71,19 @@ int main(void)
|
|||||||
printf("%u\n", item->value);
|
printf("%u\n", item->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fx_bst btree = {0};
|
fx_bst bst = {0};
|
||||||
struct btree_item items3[NITEMS] = {0};
|
struct bst_item items3[NITEMS] = {0};
|
||||||
for (int i = 0; i < NITEMS; i++) {
|
for (int i = 0; i < NITEMS; i++) {
|
||||||
items3[i].value = i;
|
items3[i].value = i;
|
||||||
put_node(&btree, &items3[i]);
|
put_node(&bst, &items3[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
|
||||||
fx_bst_iterator it3;
|
fx_bst_iterator it3;
|
||||||
fx_bst_foreach (&it3, &btree) {
|
fx_bst_foreach (&it3, &bst) {
|
||||||
struct btree_item *item
|
struct bst_item *item
|
||||||
= fx_unbox(struct btree_item, it3.node, node);
|
= fx_unbox(struct bst_item, it3.node, node);
|
||||||
|
|
||||||
for (size_t i = 0; i < it3.depth; i++) {
|
for (size_t i = 0; i < it3.depth; i++) {
|
||||||
fputs(" ", stdout);
|
fputs(" ", stdout);
|
||||||
@@ -92,10 +92,10 @@ int main(void)
|
|||||||
printf("%d\n", item->value);
|
printf("%d\n", item->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fx_bst_iterator_begin(&btree, &it3);
|
fx_bst_iterator_begin(&bst, &it3);
|
||||||
while (fx_bst_iterator_is_valid(&it3)) {
|
while (fx_bst_iterator_is_valid(&it3)) {
|
||||||
struct btree_item *item
|
struct bst_item *item
|
||||||
= fx_unbox(struct btree_item, it3.node, node);
|
= fx_unbox(struct bst_item, it3.node, node);
|
||||||
|
|
||||||
if (item->value == 9) {
|
if (item->value == 9) {
|
||||||
fx_bst_iterator_erase(&it3);
|
fx_bst_iterator_erase(&it3);
|
||||||
@@ -106,9 +106,9 @@ int main(void)
|
|||||||
|
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
|
||||||
fx_bst_foreach (&it3, &btree) {
|
fx_bst_foreach (&it3, &bst) {
|
||||||
struct btree_item *item
|
struct bst_item *item
|
||||||
= fx_unbox(struct btree_item, it3.node, node);
|
= fx_unbox(struct bst_item, it3.node, node);
|
||||||
|
|
||||||
for (size_t i = 0; i < it3.depth; i++) {
|
for (size_t i = 0; i < it3.depth; i++) {
|
||||||
fputs(" ", stdout);
|
fputs(" ", stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user