From 7459b08d8bb5f950ac2a5de2b5d8f91e646310ea Mon Sep 17 00:00:00 2001 From: 0scar Date: Tue, 30 Aug 2022 20:28:05 +0200 Subject: Update readme --- README.md | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 85dd9eb..80e8d1c 100644 --- a/README.md +++ b/README.md @@ -12,35 +12,48 @@ BTrees are -- algorithm wise -- implemented using pointers to subtrees which is horribly slow on hardware. This project aims to optimize this, by putting the whole struct into an array which can be iterated through in-order. - -## Installation - -todo +The implementation follows the algorithm described in CLRS. ## Usage -todo +```C +// define a comparator function +int cmp_int(const void *a, const void *b) { + return *(const int*)a - *(const int*)b; +} +... +// Create a new btree +// 16 is the "degree" of the tree, different sizes might pose better performance +// depending on the data you're storing +struct btree *tree = btree_new(sizeof(int), 16, &cmp_int); -# Progress +// add values +int a = 42; +int b = 3; +int c = 13; -## Naive +btree_insert(tree, &a); +btree_insert(tree, &b); +btree_insert(tree, &c); -* [x] Searching -* [x] Insertion -* [x] Deletion +{ + int searchkey = 42; + // search returns a pointer to the internal elements, NULL if not found + int *ret = btree_search(tree, &searchkey); +} +// free up the btree when you're done. +btree_free(&tree); +``` -## Flat-sequential +See the respective example branches for more examples. -* [ ] Searching -* [ ] Insertion -* [ ] Deletion +## Installation -## Parallel - -* [ ] Searching -* [ ] Insertion -* [ ] Deletion +You can run `make lib` to create a shared object file to which you can either +link to and adding the directory of the .so file to your `LD_LIBRARY_PATH` +environment variable, or move into `/usr/lib`. +There's currently not a make target to install it system wide yet. -- cgit v1.3