summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-04-01 23:43:31 +0600
committerDaniil Baturin <daniil@baturin.org>2015-04-01 23:43:31 +0600
commit13e194a7bcf3161f05bcfb55d1433d46601018a3 (patch)
treeeea504a3a912e9d5d62ca37246dde32344649821 /src
parent86a5e1a1a62474b22e0f8435228acd88c8813330 (diff)
downloadvyconf-13e194a7bcf3161f05bcfb55d1433d46601018a3.tar.gz
vyconf-13e194a7bcf3161f05bcfb55d1433d46601018a3.zip
Add Vytree.update for updating the data attached to nodes.
Diffstat (limited to 'src')
-rw-r--r--src/vytree.ml5
-rw-r--r--src/vytree.mli2
2 files changed, 7 insertions, 0 deletions
diff --git a/src/vytree.ml b/src/vytree.ml
index de482ce..89743fb 100644
--- a/src/vytree.ml
+++ b/src/vytree.ml
@@ -86,6 +86,11 @@ let rec insert default_data node path data =
let delete node path =
do_with_child delete_immediate node path
+let update node path data =
+ let update_data data' node' dummy =
+ {node' with data=data'}
+ in do_with_child (update_data data) node path
+
let rec get node path =
match path with
| [] -> raise Empty_path
diff --git a/src/vytree.mli b/src/vytree.mli
index 9b91c80..fbe7ac1 100644
--- a/src/vytree.mli
+++ b/src/vytree.mli
@@ -15,6 +15,8 @@ val insert : 'a -> 'a t -> string list -> 'a -> 'a t
val delete : 'a t -> string list -> 'a t
+val update : 'a t -> string list -> 'a -> 'a t
+
val list_children : 'a t -> string list
val get : 'a t -> string list -> 'a t