X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fnaive_tree.ml;h=a13a56dd21b1616283df446ad9fe383c39ba2728;hb=1947a98f419c2bf50378fed783406818b010c60e;hp=38421e0ad766ec72799de4f75bc9872fffa84ab8;hpb=35abea737ead2d4fd121d0cb8bdbda38cfcaa8d3;p=tatoo.git diff --git a/src/naive_tree.ml b/src/naive_tree.ml index 38421e0..a13a56d 100644 --- a/src/naive_tree.ml +++ b/src/naive_tree.ml @@ -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