c – 如何使用libavl?

我正在尝试将GNU libavl(
http://adtinfo.org/)用于我的一个学术项目.我需要一个关于如何使用库提供的BST(二进制搜索树)实现的简单教程.我需要做的是根据值使用BST对(键,值)对(大约30000个字符串和那些频率)进行排序.尽管该库已有详细记录,但它没有给出我的问题的任何直接前言答案,我没有时间阅读所有文档和测试代码.我想知道是否有更快的方法来进行排序. 最佳答案 你试过这个吗?

https://github.com/yapbreak/avl/blob/master/example/example.c

片段:

int main(int argc, char **argv)
{
    tree *avl_tree = NULL;
    struct data tmp;
    unsigned result;

    (void) argc;
    (void) argv;

    // Initialize a new tree with our three previously defined
    // functions to store data structure.
    avl_tree = init_dictionnary(data_cmp, data_print, data_delete, data_copy);

    tmp.key = 42;
    tmp.value = 4242;

    // Add element {42, 4242} in our tree.
    result = insert_elmt(avl_tree, &tmp, sizeof(struct data));
点赞