From f8f24f8c67fe903e267ab29bb2fbb9d334a722de Mon Sep 17 00:00:00 2001 From: nasr Date: Sun, 8 Mar 2026 12:55:27 +0000 Subject: feature(main): btree node operations --- source/storage/b_tree.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source/storage') diff --git a/source/storage/b_tree.c b/source/storage/b_tree.c index 4b42496..6a0e76d 100644 --- a/source/storage/b_tree.c +++ b/source/storage/b_tree.c @@ -1,14 +1,25 @@ -// TODO(nasr): -// 1. splitting the tree when getting too big? (horizontally) -// 2. joining trees? +// TODO(nasr): 1. splitting the tree when getting too big? (horizontally) 2. joining trees? - -internal void -b_tree_create(mem_arena *arena, u16 order) +internal b_tree_node * +node_alloc(mem_arena *arena) { + b_tree_node *node = PushStructZero(arena, type); + node->leaf = 1; + return node; +} +// NOTE(nasr): @return the index of of the found element +internal i32 +node_find_pos(mem_arena *arena, string8 value) +{ + i32 i = 0; + while (i < n->key_count && str8_cmp(n->keys[i], k) < 0) + { + ++i; + } + return i; } // NOTE(nasr): nodes that get passed as parameters should've already been loaded into memory -- cgit v1.3