code function that can insert into both searchList and buffer

This commit is contained in:
2026-02-08 02:32:32 +00:00
parent 1fa2a44a2f
commit c28ae4d8cd
3 changed files with 52 additions and 0 deletions

View File

@@ -538,6 +538,27 @@ struct
LEAF (items, sizes)
end
fun incrementBy (incBy, tree) =
case tree of
BRANCH (nodes, sizes) =>
let
val child = incrementBy (incBy, Vector.sub (nodes, 0))
val nodes = Vector.update (nodes, 0, child)
val sizes = Vector.map (fn sz => sz + incBy) sizes
in
BRANCH (nodes, sizes)
end
| LEAF (items, sizes) =>
let
val items = Vector.map
(fn {start, finish} =>
{start = start - incBy, finish = finish - incBy}
) items
val sizes = Vector.map #finish items
in
LEAF (items, sizes)
end
fun countDepthLoop (counter, tree) =
case tree of
BRANCH (nodes, _) => countDepthLoop (counter + 1, Vector.sub (nodes, 0))