Ajout des fonctions is_next_sibling, is_first_child, prev_sibling et parent_of_first
[tatoo.git] / src / naive_tree.ml
index 38421e0..a13a56d 100644 (file)
@@ -327,6 +327,13 @@ let root t = t.root
 let size t = t.size
 let first_child _ n = n.first_child
 let next_sibling _ n = n.next_sibling
+
+let is_first_child _ n = n.parent.first_child == n
+let is_next_sibling _ n = n.parent.next_sibling == n
+
+let prev_sibling t n = if is_next_sibling t n then n.parent else nil
+let parent_of_first t n = if is_first_child t n then n.parent else nil
+
 let parent _ n = n.parent
 let tag _ n = n.tag
 let data _ n = n.data