A virtual currency betting bot for Twitch chat. https://ddark.net/better
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
better/src/ost.h

41 lines
1.0 KiB

#ifndef _OST_H
#define _OST_H
#include <stdint.h>
typedef int (*ost_compare_fn)(const void*, const void*);
typedef void* (*ost_alloc_fn)(size_t);
typedef void (*ost_free_fn)(void*);
typedef struct ost_node ost_node;
typedef struct ost ost;
struct ost_node
{
void* data;
ost_node *left, *right, *parent;
int depth_left, depth_right, weight_left, weight_right;
};
struct ost
{
ost_node* root;
ost_compare_fn comp_fn;
ost_alloc_fn alloc_fn;
ost_free_fn free_fn;
};
void ost_init(ost* tree, int (*comp_fn)(const void*, const void*), void* (*alloc_fn)(size_t), void (*free_fn)(void*));
void ost_remove_all(ost* tree);
ost_node* ost_insert(ost* tree, void* data);
ost_node* ost_find(ost* tree, const void* data);
int ost_count(ost* tree);
ost_node* ost_inorder_first(ost* tree);
ost_node* ost_inorder_last(ost* tree);
ost_node* ost_inorder_next(ost_node* node);
ost_node* ost_inorder_prev(ost_node* node);
ost_node* ost_select(ost* tree, int index);
int ost_index_of(ost_node* node);
int ost_rank_of(ost* tree, ost_node* node);
#endif // _OST_H