Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fp-succinct-trees-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Mehren
fp-succinct-trees-1
Commits
7de8f344
Commit
7de8f344
authored
7 years ago
by
frederik stehli
Browse files
Options
Downloads
Patches
Plain Diff
[bp_tree] all tests running now
parent
d1b43f1c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bp_tree.rs
+11
-9
11 additions, 9 deletions
src/bp_tree.rs
with
11 additions
and
9 deletions
src/bp_tree.rs
+
11
−
9
View file @
7de8f344
...
...
@@ -105,8 +105,11 @@ impl<L: PartialEq + Clone + Debug> SuccinctTree<BPTree<L>, L> for BPTree<L> {
/// * `NoSiblingError` If `index` has no further siblings.
fn
next_sibling
(
&
self
,
index
:
u64
)
->
Result
<
u64
,
NodeError
>
{
let
parent_a
=
self
.parent
(
index
)
?
;
println!
(
"parent: {}"
,
parent_a
);
let
sibling
=
self
.minmax
.find_close
(
index
)
?
+
1
;
println!
(
"sibling: {}"
,
sibling
);
let
parent_b
=
self
.parent
(
sibling
)
?
;
println!
(
"parent_b: {}"
,
parent_b
);
if
parent_a
==
parent_b
{
Ok
(
sibling
)
}
else
{
...
...
@@ -148,7 +151,7 @@ impl<L: PartialEq + Clone + Debug> SuccinctTree<BPTree<L>, L> for BPTree<L> {
fn
child_label
(
&
self
,
index
:
u64
)
->
Result
<&
L
,
NodeError
>
{
self
.is_valid_index
(
index
)
?
;
self
.labels
.get
(
index
as
usize
)
.get
(
(
self
.pre_rank
(
index
)
.unwrap
()
-
1
)
as
usize
)
.ok_or
(
NodeError
::
NoLabelError
)
}
...
...
@@ -162,8 +165,12 @@ impl<L: PartialEq + Clone + Debug> SuccinctTree<BPTree<L>, L> for BPTree<L> {
fn
labeled_child
(
&
self
,
index
:
u64
,
label
:
L
)
->
Result
<
u64
,
NodeError
>
{
self
.is_valid_index
(
index
)
?
;
let
first_child
=
self
.first_child
(
index
)
?
;
if
*
self
.child_label
(
first_child
)
?
==
label
{
return
Ok
(
first_child
);
}
let
mut
sibling
=
first_child
;
while
self
.next_sibling
(
first_child
)
.err
()
.is_none
()
{
let
sibling
:
u64
=
self
.next_sibling
(
index
)
?
;
sibling
=
self
.next_sibling
(
sibling
)
?
;
if
*
self
.child_label
(
sibling
)
?
==
label
{
return
Ok
(
sibling
);
}
...
...
@@ -515,15 +522,10 @@ mod tests {
assert_eq!
(
*
bp_tree
.child_label
(
0
)
.unwrap
(),
"root"
);
assert_eq!
(
*
bp_tree
.child_label
(
1
)
.unwrap
(),
"first_root_child"
);
assert_eq!
(
*
bp_tree
.child_label
(
2
)
.unwrap
(),
"leaf"
);
assert_eq!
(
*
bp_tree
.child_label
(
3
)
.unwrap
(),
"second_root_child"
);
assert_eq!
(
bp_tree
.child_label
(
4
)
.err
()
.unwrap
(),
NodeError
::
NoLabelError
);
assert_eq!
(
*
bp_tree
.child_label
(
5
)
.unwrap
(),
"second_root_child"
);
}
#[test]
#[ignore]
fn
labeled_child
()
{
let
mut
id_tree
:
Tree
<
String
>
=
TreeBuilder
::
new
()
.with_node_capacity
(
5
)
.build
();
let
root_id
:
NodeId
=
id_tree
...
...
@@ -557,6 +559,6 @@ mod tests {
.unwrap
(),
1
);
assert_eq!
(
bp_tree
.labeled_child
(
1
,
String
::
from
(
"leaf"
))
.unwrap
(),
3
);
assert_eq!
(
bp_tree
.labeled_child
(
1
,
String
::
from
(
"leaf"
))
.unwrap
(),
2
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment