diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2022-08-30 18:28:05 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2022-08-30 18:29:54 +0000 |
| commit | 7459b08d8bb5f950ac2a5de2b5d8f91e646310ea (patch) | |
| tree | f04dbb4e7c36cd34f79218676dfd6a9fe1aa68d5 /README.md | |
| parent | 22209027458ee286d19d541332e815adcb82b62a (diff) | |
Update readme
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 51 |
1 files changed, 32 insertions, 19 deletions
@@ -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. |
