Massive backlog of changes

This commit is contained in:
2022-06-15 15:59:31 -05:00
parent c962a83ff0
commit a52f06f81e
49 changed files with 1855 additions and 1083 deletions

41
include/avltree.h Normal file
View File

@@ -0,0 +1,41 @@
#pragma once
/**
* @brief An AVL tree.
*
*/
struct avltree_t {
int height;
int key;
void *value;
struct avltree_t *left, *right;
};
/**
* @brief Inserts a new node into an AVL tree.
*
* A new node will be allocated and assigned the provided key and value.
*
* @param tree A pointer to the tree to insert into.
* @param key The key to associate the new node with.
* @param value A pointer to store into the new node.
*/
struct avltree_t *avl_insert(struct avltree_t *tree, int key, void *value);
/**
* @brief Removes the node associated with `key` from `tree`.
*
* @param tree A pointer to the tree to remove from.
* @param key The key of the node to remove.
* @return struct avltree_t* The pointer stored in the node that was just removed.
*/
struct avltree_t *avl_remove(struct avltree_t *tree, int key);
/**
* @brief Searches for a node in `tree` with a matching key, and returns the
*
* @param tree
* @param key
* @return void*
*/
void *avl_get(struct avltree_t *tree, int key);