Skip to content
Snippets Groups Projects
Verified Commit b82c8097 authored by Kevin Kaßelmann's avatar Kevin Kaßelmann Committed by David Mehren
Browse files

Changed method signature

parent b76c930f
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ pub trait SuccinctTree<T, Label>: Debug {
fn first_child(&self, index: u64) -> Result<u64, NodeError>;
fn next_sibling(&self, index: u64) -> Result<u64, NodeError>;
fn from_id_tree(tree: Tree<i32>) -> Result<T, EmptyTreeError>;
fn child_label(&self, index: u64) -> Result<Label, NodeError>;
fn child_label(&self, index: u64) -> Result<&Label, NodeError>;
fn labeled_child(&self, index: u64, label: Label) -> Result<u64, NodeError>;
/// Prüft ob ein Bitvector ein gültiger SuccinctTree ist, anhand des gültigen Exzesses und
......
......@@ -138,9 +138,9 @@ impl<L> SuccinctTree<BPTree<L>, L> for BPTree<L> {
/// # Arguments
/// * `index` The index of the node to get the label of
/// # Errors
/// * `NotANodeError` If `index` does not reference a node.
fn child_label(&self, index: u64) -> Result<L, NodeError> {
unimplemented!();
/// * `NoLabelError` If `index` does not reference a node with a label.
fn child_label(&self, index: u64) -> Result<&L, NodeError> {
self.labels.get(index as usize).ok_or(NodeError::NoLabelError)
}
/// Returns the child from the specified node with that label
......@@ -151,6 +151,7 @@ impl<L> SuccinctTree<BPTree<L>, L> for BPTree<L> {
/// * `NoSuchChildError` If there is no child which has this label
fn labeled_child(&self, index: u64, label: L) -> Result<u64, NodeError> {
unimplemented!();
}
}
......
......@@ -153,7 +153,7 @@ impl<L> SuccinctTree<LOUDSTree<L>, L> for LOUDSTree<L> {
/// * `index` The index of the node to get the label of
/// # Errors
/// * `NotANodeError` If `index` does not reference a node.
fn child_label(&self, index: u64) -> Result<L, NodeError> {
fn child_label(&self, index: u64) -> Result<&L, NodeError> {
unimplemented!();
}
......@@ -250,7 +250,8 @@ mod tests {
let tree: LOUDSTree<String> = LOUDSTree::from_bitvec(bitvec.clone()).unwrap();
tree.save_to("testdata/loudstree.testdata".to_string())
.unwrap();
let result: LOUDSTree<String> = LOUDSTree::from_file("testdata/loudstree.testdata".to_string()).unwrap();
let result: LOUDSTree<String> =
LOUDSTree::from_file("testdata/loudstree.testdata".to_string()).unwrap();
assert_eq!(
tree, result,
"The loaded tree is not equal to the original one."
......@@ -388,7 +389,6 @@ mod tests {
assert_ne!(tree_a, tree_c)
}
#[test]
fn from_id_tree() {
let mut id_tree: Tree<i32> = TreeBuilder::new().with_node_capacity(5).build();
......@@ -406,9 +406,6 @@ mod tests {
fn from_empty_id_tree() {
let id_tree: Tree<i32> = TreeBuilder::new().with_node_capacity(5).build();
let tree: Result<LOUDSTree<String>, EmptyTreeError> = LOUDSTree::from_id_tree(id_tree);
assert_eq!(
tree.unwrap_err(),
EmptyTreeError
);
assert_eq!(tree.unwrap_err(), EmptyTreeError);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment