Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISC_144 - B+ Tree Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
florian.burgener
ISC_144 - B+ Tree Project
Compare revisions
637147eadec6df552144f49c7407164ff7c40288 to 15d3386f9e16c5dc07dbd396f2a2ddfddd929019
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
florian.burgener/bptree-project
Select target project
No results found
15d3386f9e16c5dc07dbd396f2a2ddfddd929019
Select Git revision
Branches
main
1 result
Swap
Target
florian.burgener/bptree-project
Select target project
florian.burgener/bptree-project
1 result
637147eadec6df552144f49c7407164ff7c40288
Select Git revision
Branches
main
1 result
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Fix linked list
· 412ba274
Florian Burgener
authored
2 years ago
412ba274
Change comments
· 15d3386f
Florian Burgener
authored
2 years ago
15d3386f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/BPTree.c
+11
-11
11 additions, 11 deletions
src/BPTree.c
src/tests/BPTreeTests.c
+3
-3
3 additions, 3 deletions
src/tests/BPTreeTests.c
with
14 additions
and
14 deletions
src/BPTree.c
View file @
15d3386f
...
...
@@ -322,29 +322,29 @@ static bool is_sibling_left_side(BPTreeNode *parent, BPTreeNode *node, BPTreeNod
static
void
merge
(
BPTreeNode
*
parent
,
BPTreeNode
*
left_node
,
BPTreeNode
*
right_node
)
{
int
index_in_children
=
BPTreeNodeArray_search
(
parent
->
children
,
left_node
);
if
(
!
righ
t_node
->
is_leaf
)
{
IntegerArray_
insert_at_index
(
righ
t_node
->
keys
,
0
,
parent
->
keys
->
items
[
index_in_children
]);
if
(
!
lef
t_node
->
is_leaf
)
{
IntegerArray_
append
(
lef
t_node
->
keys
,
parent
->
keys
->
items
[
index_in_children
]);
}
// Merge the keys.
for
(
int
i
=
lef
t_node
->
keys
->
size
-
1
;
i
>=
0
;
i
--
)
{
IntegerArray_
insert_at_index
(
righ
t_node
->
keys
,
0
,
lef
t_node
->
keys
->
items
[
i
]);
for
(
int
i
=
0
;
i
<
righ
t_node
->
keys
->
size
;
i
++
)
{
IntegerArray_
append
(
lef
t_node
->
keys
,
righ
t_node
->
keys
->
items
[
i
]);
}
// Merge the data.
for
(
int
i
=
lef
t_node
->
data
->
size
-
1
;
i
>=
0
;
i
--
)
{
IntegerArray_
insert_at_index
(
righ
t_node
->
data
,
0
,
lef
t_node
->
data
->
items
[
i
]);
for
(
int
i
=
0
;
i
<
righ
t_node
->
data
->
size
;
i
++
)
{
IntegerArray_
append
(
lef
t_node
->
data
,
righ
t_node
->
data
->
items
[
i
]);
}
// Merge the children.
for
(
int
i
=
lef
t_node
->
children
->
size
-
1
;
i
>=
0
;
i
--
)
{
BPTreeNodeArray_
insert_at_index
(
righ
t_node
->
children
,
0
,
lef
t_node
->
children
->
items
[
i
]);
for
(
int
i
=
0
;
i
<
righ
t_node
->
children
->
size
;
i
++
)
{
BPTreeNodeArray_
append
(
lef
t_node
->
children
,
righ
t_node
->
children
->
items
[
i
]);
}
IntegerArray_delete_at_index
(
parent
->
keys
,
index_in_children
);
BPTreeNodeArray_delete_at_index
(
parent
->
children
,
index_in_children
);
BPTreeNode_destroy
(
&
lef
t_node
);
BPTreeNodeArray_delete_at_index
(
parent
->
children
,
index_in_children
+
1
);
left_node
->
next
=
right_node
->
next
;
BPTreeNode_destroy
(
&
righ
t_node
);
}
static
void
steal_leaf
(
BPTreeNode
*
parent
,
BPTreeNode
*
node
,
BPTreeNode
*
sibling
)
{
...
...
This diff is collapsed.
Click to expand it.
src/tests/BPTreeTests.c
View file @
15d3386f
...
...
@@ -314,7 +314,7 @@ static void test_BPTree_insert_should_comply_with_BPTree_rules_using_BPTree_of_g
for
(
int
i
=
0
;
i
<
keys
->
size
;
i
++
)
{
BPTree_insert
(
root
,
keys
->
items
[
i
],
transform_key_to_data
(
keys
->
items
[
i
]));
// After each insertion,
we
check that the B+ tree
is compliant with
the B+
T
ree
rules
.
// After each insertion,
is
check
ed
that the B+ tree
conforms to the rules of
the B+
t
ree.
TEST_ASSERT
(
check_BPTree_compliance
(
root
));
}
...
...
@@ -376,7 +376,7 @@ void test_BPTree_delete_should_comply_with_BPTree_rules_using_BPTree_of_given_or
while
(
keys
->
size
>
0
)
{
int
index
=
rand
()
%
keys
->
size
;
BPTree_delete
(
root
,
keys
->
items
[
index
]);
// After each deletion,
we
check that the B+ tree conforms to the B+
T
ree
rules
.
// After each deletion,
is
check
ed
that the B+ tree conforms to the
rules of the
B+
t
ree.
TEST_ASSERT
(
check_BPTree_compliance
(
root
));
IntegerArray_delete_at_index
(
keys
,
index
);
}
...
...
@@ -437,7 +437,7 @@ void test_BPTree_search_should_find_the_keys_that_exist_in_the_BPTree_using_BPTr
uint64_t
data
;
bool
is_found
=
BPTree_search
(
root
,
keys
->
items
[
i
],
&
data
);
// After each search,
we
check that the key has been found and that the relationship between it and the data is correct.
// After each search,
is
check
ed
that the key has been found and that the relationship between it and the data is correct.
TEST_ASSERT
(
is_found
);
TEST_ASSERT_EQUAL_UINT64
(
transform_key_to_data
(
keys
->
items
[
i
]),
data
);
}
...
...
This diff is collapsed.
Click to expand it.