Hi. Please consider following code:
module Set = Reins.AVLSet.MonoSet(Reins.Types.Int)
module Iter = Reins.TreeSetIterator.Make(Set)
let l = [3;5;2;7;4;8;1]
let s = List.fold_left (fun s v -> Set.add v s) Set.empty l
let dir = Iter.Ascending Iter.InOrder
let m = 3
let trav = Iter.Traverse_While (fun n -> n <= m)
let iter = Iter.create dir trav s
let _ = Iter.iter (fun k -> print_string (string_of_int k ^ " ")) iter
which prints out
1 2 3 4
What is the semantics of Traverse_While? I was expecting the iterator to stop at 3. The iterator seems to go one element extra. Trying with m = 0 prints the value 1 even though the predicate given to Traverse_While is never satisfied.
Also, leave m = 3, and remove 2 from the list. Then we get Exception: Failure "get_value".
Alternatively, leave the list as shown above and set m = 7. I was expecting same error again, but there is no Failure this time.